Answer to Question #4383 in Other Programming & Computer Science for Jackie

Question #4383
Use pseudocode to design a suitable program. In your program, make use of subprograms with parameters and arguments. Develop a menu-driven program that inputs a number X, and at the user&#039;s option, finds and displays the area (A) of one of the following: * A square with side X, A = x^2 * A circle with radius X, A = 3.14 * X^2 * An equilateral triangle with side X, A = Sqrt (3) / 4 * X^2
// Question_4383.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "cmath"
using namespace std;
int A_square_with_side_X(
const int X
);
const int X
);
float An_equilateral_triangle_with_side_X(
const int X
);
int _tmain(int argc, _TCHAR* argv[])
{
for(;;){
cout << "1. A square with side X\n";
cout << "2. A circle with radius X\n";
cout << "3. An equilateral triangle with side X\n";
cout << "4. exit \n";
cout << "? >>";
int num;
cin >> num;
switch(num){
case 1:{
int X;
cout << "input X >>";
cin >> X;
cout << "A =" << A_square_with_side_X(X)<<"\n";
break;
};
case 2:{
int X;
cout << "input X >>";
cin >> X;
cout << "A =" << A_circle_with_radius_X(X)<<"\n";
break;
};
case 3:{
int X;
cout << "input X >>";
cin >> X;
cout << "A =" << An_equilateral_triangle_with_side_X(X)<<"\n";
break;
};
case 4:{
exit(0);
}
};
}
return 0;
};
int A_square_with_side_X(
const int X
)
{
return X*X;
};
const int X
)
{
return 3.14*( X * X);
};
float An_equilateral_triangle_with_side_X(
const int X
)
{
return sqrt(3.0)/(4*(X*X));
};

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!