Question
Hello, I'm supposed to create a volume calculator and have the most of the code written, but don't know how to write the code for
Hello, I'm supposed to create a volume calculator and have the most of the code written, but don't know how to write the code for number 4. in the instruction. Can someone help? thanks.
#include
void cube(); void rectangularPrism(); void cylinder(); void pyramid(); void cone(); void sphere();
double side = 0.0; double a = 0.0; double b = 0.0; double c = 0.0; double r = 0.0; double h = 0.0;
char answer; char choice; char unit;
double pi = (22.0/7.0);
void cube(){ double Vol; Vol = pow(side, 3); cout
cout > first; cout > last; system ("cls"); cout
do { cout
{
cout > choice;
if (choice == 'A' || choice == 'a') { cout > side; cube(); system ("pause"); } else if (choice == 'B' || choice == 'b') { cout > a; cout > b; cout > c; rectangularPrism(); system ("pause"); } else if (choice == 'C' || choice == 'c') { cout > r; cout > h; cylinder(); system ("pause"); } else if (choice == 'D' || choice == 'd') { cout > b; cout > h; pyramid(); system ("pause"); } else if (choice == 'E' || choice == 'e') { cout > r; cout > h; cone(); system ("pause"); } else if (choice == 'F' || choice == 'f') { cout > r; sphere(); system ("pause"); } cout > answer;
} } while (answer != 'N' || answer != 'n'); exit(0); }
Objective: To write a program using functions that will prompt the user to enter in values for variables used to calculate the volume of the shapes listed in the Volume Formulas table below on page 2 To incorporate the switch command to choose which shape the user wants to calculate for * Write the program that will: 1. 2. Tell a user to enter in their first and last name Will greet the user with the following greeting Hello Jon DOE welcome to the volume calculator, 3. Will then offer to the user a choice of which shape to calculate the volume of This choice must be in character and not number, it must take in account error checking (wrong input must inform the user that that is not one of the choices please enter in a correct choice). It also must take into account both upper and lower case letters to be correct a. i. A) cube ii. B) sphere iii. C) etc Must give the user a choice of units to calculate in or must give the calculated volume in meters, inches, centimeters, and feet.] Will then ask for the appropriate values required to calculate for the chosen shape Will print out to the user the calculated volume and values entered along with the variable they represent 4. 5. 6. a. For a sphere with the given radius "entered value" the calculated volume is "answer" b. For a cube with the given sides "entered value" the calculated volume is "answer" The program must not terminate on its' own, it must give the user a choice to re run the program or to end the program. It must also give the user and end script. Special instructions 7. 8. a. Use double data types so the space is large enough for the answer b. Use 22.0/7.0 for the value of pi c. The program must ask the user if they would like to calculate for another shape or end the progran, i. Example I. Please Enter "y" to rerun the program or "n to end the program (you must account for both lower and upper case answers) 9. Each shape calculation must be in their own function and called depending on the menu choiceStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started