Answer to Question #159860 in C++ for Paper boii

Question #159860

1. Write a float function rectangle() that computes and returns the area of a rectangle using its two float formal parameters h and w, where h is the height and w is the width of the rectangle.

2. Write a function called isEven() that uses the remainder operator(%) to determine whether an integer is even or not.

3. Write a program with function name "ourmemeber" that displays your group members name and Id No correctly. Give example with random names and id.


1
Expert's answer
2021-01-30T06:37:41-0500
#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <iomanip>
using namespace std;
float rectangle (float h, float w) {
    return h * w;
}
bool isEven (int n) {
    return n % 2 == 0 ? true : false;
}
void ourmember (int n) {
    srand(time(0));
    string names[10] = {"John", "Eyler", "Nyuton", "Liza", "Eiyshli", "Scoffield", "Kasper", "Mike", "Eliza", "Jack"};
    cout << setw(20) << "Member Name |" << setw(20) << "Member Id |" << endl;
    for (int i = 0; i < n; i++) {
        int index = rand() % 10;
        int id = rand() % 900000 + 100000;
        cout << setw(18) << names[index] << " |" << setw(18) << id << " |\n"; 
    }
}
int main () {
    float height, width;
    cout << "Enter height of rectangle: "; cin >> height;
    cout << "Enter width of rectangle: "; cin >> width;
    float area;
    area = rectangle(height, width);
    cout << "Area of rectangle is: " << area << endl;
    int integer;
    cout << "Enter a integer: "; cin >> integer;
    if (isEven(integer)) {
        cout << "Entered integer is even\n";
    }
    else {
        cout << "Entered integer isn't even\n";
    }
    int n;
    cout << "How many people in your group: "; cin >> n;
    ourmember(n);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog