I need this program to have function prototype, calling and function definition. I also need to keep the switch function #include using namespace std; int main() { int number; cout << "Astronomy Helper" <> number; cout <= 1 && number <=5)//if choice between 1-4 { switch (number) { case 1: //user chooses option 1, calculate area of circle cout << "Mercury" << endl; cout<< "Average distance from sun: 57.9 million kilometers"<
I need this
#include <iostream>
using namespace std;
int main()
{
int number;
cout << "Astronomy Helper" <<endl;
cout <<endl;
cout << "Menu Selection" << endl;
cout << "1. Mercury" << endl;
cout << "2. Venus" << endl;
cout << "3. Earth" << endl;
cout << "4. Mars" << endl;
cout << "5. End the Program" << endl;
cout << "Enter your selection [1 - 5]: ";
cin >> number;
cout <<endl;
if (number >= 1 && number <=5)//if choice between 1-4
{
switch (number)
{
case 1: //user chooses option 1, calculate area of circle
cout << "Mercury" << endl;
cout<< "Average distance from sun: 57.9 million kilometers"<<endl;
cout << "Mass: 3.31 x 10^23 kg" <<endl;
cout << "Surface Temperature: -173 to 430 degrees Celsius" << endl;
break;
case 2://user chooses option 2, calculate area of rectangle
cout << "Venus" << endl;
cout<< "Average distance from sun: 108.2 million kilometers"<<endl;
cout << "Mass: 4.87 x 10^24 kg" <<endl;
cout << "Surface Temperature: 472 degrees Celsius" << endl;
break;
case 3:
cout << "Earth" << endl;
cout<< "Average distance from sun: 149.6 million kilometers"<<endl;
cout << "Mass: 5.967 x 10^24 kg" <<endl;
cout << "Surface Temperature: -50 to 50 degrees Celsius" << endl;
break;
case 4:
cout << "Mars" << endl;
cout<< "Average distance from sun: 227.9 million kilometers"<<endl;
cout << "Mass: 0.6424 x 10^24 kg" <<endl;
cout << "Surface Temperature: -140 to 20 degrees Celsius" << endl;
break;
case 5:
cout <<"Thank you! This program will end now!" <<endl;
break;
}
}
else if (number != 5)//if users choice not 1-4, terminate program
{
cout << "ERROR! The valid choices are only 1-4!\n";
cout << "Please run the program again.\n";
}
return 0;}

Step by step
Solved in 2 steps with 1 images









