1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//declaring variables and arrays
double planetCalc[8] = {0.5,0.6 ,0.7, 0.8,0.9,0.1,0.2,0.3};
string planetName[8] = { "Mars", "Earth", "Mercury", "Venus", "Jupiter", "Pluto", "Uranus", "Saturn" };
int weight = 0;
string name = "";
double answer = 0.0;
int planetNum= 0;
bool repeat = true;
while (repeat == true) {
cout << "1- Mars, 2-Earth, 3-Mercury, 4-Venus, 5-Jupiter, 6-Pluto, 7-Uranus, 8-Saturn -- Enter -1 to Quit" << endl;
cout << "What planet code would you like to use: ";
cin >> planetNum;
if (planetNum == -1){
repeat = false;
break;
}
cout << "What is your weight: ";
cin >> weight;
cout << "What is your name>: ";
cin >> name;
switch (planetNum)
{
case 1:
answer = weight * planetCalc[0];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 2:
answer = weight * planetCalc[1];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 3:
answer = weight * planetCalc[2];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 4:
answer = weight * planetCalc [3];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 5:
answer = weight * planetCalc[4];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 6:
answer = weight * planetCalc[5];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 7:
answer = weight * planetCalc[6];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 8:
answer = weight * planetCalc[7];
cout << name << " ,your weight on " << planetName[planetNum-1] << " is: " << answer << endl;
break;
case 9:
cout << "unnecessary error msg" << endl;
default:
cout << "You didn't select a valid option" << endl;
} //end switch
}
system("pause");
return 0;
} //end of main function
|