Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please solve this C++ program Assignment 3 Write a C+t program to do the followi

ID: 3700232 • Letter: P

Question


please solve this C++ program

Assignment 3 Write a C+t program to do the following 1. Function "ain" a. Calls function "DisplayMenue" inside a do/while to forces the user to input a number between 0 and 4 b. Accepts user's input c. Starts a "while" with sentinel value d. Start a "switch structure that checks the user's input, and accordingly it will call e. At the end of the while with sentinel, call function "DisplayMenue' and forces the necessary functions. the user to input a number between 0 and 4 f. Your program continues looping until the sentinel value is inputted 2. Write function "DisplayMenue" that takes no arguments and return no value. This funct?? displays only the below menu )Circle 2) Sphere 3) Cylinder 4) Calculator 0)Exit Please elect an item: 3. Call function "circle" that takes two double arguments by reference that represents the area and perimeter and returns no value. This function asks the user to input the circle's radius and calculates the area and perimeter, and returns these two values by reference to main. Function "main" ill output these two values. Formulas: Area- Perimeter-2 ? r 4. Call function "Sphere" that takes no argument and returns a double value. This function asks the user to input the sphere's radius, and then it calculates and returns the area to Function "main will output the area. Formula: Area-4RT2 5. Call function "Cylinder that takes two double arguments that represents radius & height and returns no value. This function calculates and prints the cylinder's area and volume Formulas: Area-2 ? r h + 2 ? r- Volume arh 6. Call function Calculator" that takes no arguments and returns an integer value. This function will do the following a. Randomly generates two numbers between 2 and 9, and output them on the screen. b. Asks the user to enter their sum, difference, and product. c. Then, it checks if the user's entered values are cormect d. Ifyes, then it displays a congratulation message. e. If no, then it output the correct answen s). f. Finally, returns to "main' the number of guessed values (i.e. I, 2, or 3)

Explanation / Answer

Please find below code for your problem

--------------------------------

#include<iostream>

using namespace std;

void DisplayMenue()

{

cout << "1 - Circle" << endl;

cout << "2 - Sphere " << endl;

cout << "3 - Cylinder" << endl;

cout << "4 - Calculator " << endl;

cout << "0 - Exit" << endl;

cout << "Please Select an item: ";

}

void Circle(double &area, double &perimeter)

{

const double Pi = 3.14159;

double radius;

cout << "Please enter circle radius: ";

cin >> radius;

area = Pi * radius * radius;

perimeter = 2 * Pi * radius;

}

double Sphere()

{

const double Pi = 3.14159;

double area, radius;

cout << "Please enter sphere radius: ";

cin >> radius;

area = 4 * Pi * radius*radius;

return area;

}

void Cylinder(double radius, double height)

{

const double Pi = 3.14159;

double Area = 2 * Pi * radius * height + 2 * Pi * radius * radius;

double Volume = Pi * radius * radius * height;

cout << "The cylinder area is: " << Area << endl;

cout << "The cylinder volume is: " << Volume << endl;

}

int Calculator()

{

int randNum1 = rand() % (9 - 2 + 1) + 2;

int randNum2 = rand() % (9 - 2 + 1) + 2;

cout << "Number 1 :" << randNum1 <<endl;

cout << "Number 2 :" << randNum2 << endl;

cout << "Please enter sum of two number displayed: ";

int rightAns = 0;

int inputAns;

cin >> inputAns;

if (inputAns == randNum1 + randNum2)

{

cout << " Congratulation !" << endl;

rightAns++;

}

else

{

cout << "Sorry the correct answer is : " << randNum1 + randNum2 << endl;

}

cout << "Please enter diffrence of two number displayed: ";

cin >> inputAns;

if (inputAns == randNum1 - randNum2)

{

cout << " Congratulation !" << endl;

rightAns++;

}

else

{

cout << "Sorry the correct answer is : " << randNum1 - randNum2 << endl;

}

cout << "Please enter product of two number displayed: ";

cin >> inputAns;

if (inputAns == randNum1 * randNum2)

{

cout << " Congratulation !" << endl;

rightAns++;

}

else

{

cout << "Sorry the correct answer is : " << randNum1 * randNum2 << endl;

}

return rightAns;

}

void main()

{

int inputNumber;

double area, perimeter;

int rightAns = 0;

do

{

DisplayMenue();

cin >> inputNumber;

switch (inputNumber)

{

case 1:

Circle(area, perimeter);

cout << "The circle area is: " << area << endl;

cout << "The circle perimeter is: " << perimeter << endl;

break;

case 2:

area = Sphere();

cout << "The sphere area is: " << area << endl;

break;

case 3:

double radius, height;

cout << "Please enter cylinder radius: ";

cin >> radius;

cout <<endl << "Please enter cylinder height: ";

cin >> height;

Cylinder(radius, height);

break;

case 4:

rightAns = Calculator();

cout << endl << "You have answred "<< rightAns << " question correctly out of 3 questions" <<endl;

break;

case 0:

break;

default:

break;

}

} while (inputNumber != 0);

DisplayMenue();

}