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

Hello, I\'m supposed to create a volume calculator and have the most of the code

ID: 3606822 • Letter: H

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 number 4. in the instruction. Can someone help? thanks.


#include <cstdio> //
#include <cstdlib> //
#include <iostream> //
#include <stdio.h> //
#include <stdlib.h>
#include <cmath>
#include <string>
using namespace std;

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 << "The volume of your cube is " << Vol << endl;
}
void rectangularPrism(){
double Vol;
Vol = a*b*c;
cout << "The volume of your rectangular prism is " << Vol << endl;
}
void cylinder(){
double Vol;
Vol = pi*pow(r,2)*h;
cout << "The volume of your cylinder is " << Vol << endl;
}
void pyramid(){
double Vol;
Vol = (.3333)*b*h;
cout << "The volume of your pyramid is " << Vol << endl;
}
void cone(){
double Vol;
Vol = (.3333)*pi*pow(r,2)*h;
cout << "The volume of your cone is " << Vol << endl;
}
void sphere(){
double Vol;
Vol = (1.3333)*pi*pow(r,3);
cout << "The volume of your sphere is " << Vol << endl;
}
int main (void)
{
char first(100);
char last (20);
char selection;
char ending;
system ("cls");

cout << "please enter you first name ";//pronts you to enter your first name
cin >> first;
cout << "please enter you last name ";// pronts you to enter your last name.
cin >> last;
system ("cls");
cout << "Hello " <<first<<" "<<last <<" "
<<"Welcome to the Volume calculator " ;
system ("pause");

do {
cout << "A: cube Calculator" << endl;
cout << "B: rectangular prism calculator"<< endl;
cout << "C: cylinder calculator" << endl;
cout << "D: pyramid calculator"<< endl;
cout << "E: cone calculator"<< endl;
cout << "F: sphere calculator" << endl;

{

cout << "Which selection do you want from the menu?" << endl;
cin >> choice;

if (choice == 'A' || choice == 'a')
{
cout << "A: cube calculator" << endl;
cout << "Please enter the side of your cube" << " ";
cin >> side;
cube();
system ("pause");
}
else if (choice == 'B' || choice == 'b') {
cout << "B: rectangular prism calculator" << endl;
cout << "Please enter the sides of the rectangular prism" << " ";
cout << "enter value a =";
cin >> a;
cout << "enter value b =";
cin >> b;
cout << "enter value c =";
cin >> c;
rectangularPrism();
system ("pause");
}
else if (choice == 'C' || choice == 'c') {
cout << "C: cylinder calculator" << endl;
cout << "Please enter the values for the cylinder" << " ";
cout << "enter the value for the radius =";
cin >> r;
cout << "please enter the value for the height";
cin >> h;
cylinder();
system ("pause");
}
else if (choice == 'D' || choice == 'd') {
cout << "D: pyramid calculator " << endl;
cout << "Please enter the values for the pyramid" << " ";
cout << "enter the value for the base =";
cin >> b;
cout << "please enter the value for the height";
cin >> h;
pyramid();
system ("pause");
}
else if (choice == 'E' || choice == 'e') {
cout << "E: cone calculator " << endl;
cout << "Please enter the values for the cone" << " ";
cout << "enter the value for the radius =";
cin >> r;
cout << "please enter the value for the height";
cin >> h;
cone();
system ("pause");
}
else if (choice == 'F' || choice == 'f') {
cout << "F: sphere calculator " << endl;
cout << "Please enter the values for the sphere" << " ";
cout << "enter the value for the radius =";
cin >> r;
sphere();
system ("pause");
}
cout << "Would you like to try another volume calculator? Y or N " << endl;
cin >> 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 choice

Explanation / Answer

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string>
using namespace std;
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 << " cube of value " << Vol << endl;
}
void rectangularPrism(){
double Vol;
Vol = a*b*c;
cout << "The volume of your rectangular prism is " << Vol << endl;
}
void cylinder(){
double Vol;
Vol = pi*pow(r,2)*h;
cout << "The volume of your cylinder is " << Vol << endl;
}
void pyramid(){
double Vol;
Vol = (.3333)*b*h;
cout << "The volume of your pyramid is " << Vol << endl;
}
void cone(){
double Vol;
Vol = (.3333)*pi*pow(r,2)*h;
cout << "The volume of your cone is " << Vol << endl;
}
void sphere(){
double Vol;
Vol = (1.3333)*pi*pow(r,3);
cout << "The volume of your sphere is " << Vol << endl;
}
int main (void)
{
char first(100);
char last (20);
char selection;
char ending;
system ("cls");
cout << "please first name ";
cin >> first;
cout << "please last name ";// pronts you to enter your last name.
cin >> last;
system ("cls");
cout << "Hello " <<first<<" "<<last <<" "
<<"Welcome to calculator " ;
system ("pause");
do {
cout << "A: cube to Calculator" << endl;
cout << "B: rectangular prism to calculator"<< endl;
cout << "C: cylinder to calculator" << endl;
cout << "D: pyramid to calculator"<< endl;
cout << "E: cone to calculator"<< endl;
cout << "F: sphere to calculator" << endl;
{
cout << "Which one you selection do you want from the menu?" << endl;
cin >> choice;
if (choice == 'A' || choice == 'a')
{
cout << "A: cube calculator" << endl;
cout << "Please enter the side of your cube" << " ";
cin >> side;
cube();
system ("pause");
}
else if (choice == 'B' || choice == 'b') {
cout << "B: rectangular prism calculator" << endl;
cout << "Please enter the sides of the rectangular prism" << " ";
cout << "enter value a =";
cin >> a;
cout << "enter value b =";
cin >> b;
cout << "enter value c =";
cin >> c;
rectangularPrism();
system ("pause");
}
else if (choice == 'C' || choice == 'c') {
cout << "C: cylinder calculator" << endl;
cout << "Please enter the values for the cylinder" << " ";
cout << "enter the value for the radius =";
cin >> r;
cout << "please enter the value for the height";
cin >> h;
cylinder();
system ("pause");
}
else if (choice == 'D' || choice == 'd') {
cout << "D: pyramid calculator " << endl;
cout << "Please enter the values for the pyramid" << " ";
cout << "enter the value for the base =";
cin >> b;
cout << "please enter the value for the height";
cin >> h;
pyramid();
system ("pause");
}
else if (choice == 'E' || choice == 'e') {
cout << "E: cone calculator " << endl;
cout << "Please enter the values for the cone" << " ";
cout << "enter the value for the radius =";
cin >> r;
cout << "please enter the value for the height";
cin >> h;
cone();
system ("pause");
}
else if (choice == 'F' || choice == 'f') {
cout << "F: sphere calculator " << endl;
cout << " enter the values for the sphere" << " ";
cout << "please enter the value for the radius =";
cin >> r;
sphere();
system ("pause");
}
cout << "will you be like to try another volume calculator? Y or N " << endl;
cin >> answer;

}
} while (answer != 'N' || answer != 'n');
exit(0);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote