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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#define M_PI 3.14
using namespace std;
string addPlanet, removePlanet;
vector<string> PlanetList;
vector<string>::iterator PlanetIter;
int choice;
bool gameOn = true;
void print(const string& item)
{cout<<item<<endl;
set<string> sortedItems;}
int main()
{
PlanetList.push_back("Mercury");
PlanetList.push_back("Venus");
PlanetList.push_back("Earth");
PlanetList.push_back("Mars");
PlanetList.push_back("Jupiter");
PlanetList.push_back("Saturn");
PlanetList.push_back("Uranus");
PlanetList.push_back("Neptune");
int numberOfPlanets = PlanetList.size();
while (gameOn != false){
cout << "*******************************\n";
cout << " 1 - Murcury\n";
cout << " 2 - Venus\n";
cout << " 3 - Earth\n";
cout << " 4 - Mars\n";
cout << " 5 - Jupiter\n";
cout << " 6 - Saturn\n";
cout << " 7 - Uranus\n";
cout << " 8 - Neptune\n";
cout << " 9 - Add A Planet\n";
cout << " 10 - Delete A Planet\n";
cout << " 11 - Sort\n";
cout << " 12 - Auto-Sort\n";
cout << " 13 - Quit\n";
cout << "*******************************\n";
cout << " Enter your choice and press return: ";
cin >> choice;
switch (choice)
{
{case 1:
cout<<"~~~~Murcury~~~~\n";
cout<<"The Mass is 3.3022x10^23 KG.\n";
cout<<"The Radius is 4,880 KM.\n";
double mass=3.3022*pow(10,23);
double rad=4880;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 2:
cout<<"~~~~Venus~~~~\n";
cout<<"The Mass is 4.8685x10^24 KG.\n";
cout<<"The Radius is 12,103.6 KM.\n";
double mass=4.8685*pow(10,24);
double rad=12103.6;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 3:
cout<<"~~~~Earth~~~~\n";
cout<<"The Mass is 5.972x10^24.\n";
cout<<"The Radius is 12,756.3 KM.\n";
double mass=5.972*pow(10,24);
double rad=12756.3 ;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 4:
cout<<"~~~~Mars~~~~\n";
cout<<"The Mass is 6.4219x10^23 KG.\n";
cout<<"The Radius is 6,794KM.\n";
double mass=4.8685*pow(10,23);
double rad=6794;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 5:
cout<<"~~~~Jupiter~~~~\n";
cout<<"The Mass is 1.900ex10^27 KG.\n";
cout<<"The Radius is 142984KM.\n";
double mass=4.8685*pow(10,27);
double rad=142984;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 6:
cout<<"~~~~Saturn~~~~\n";
cout<<"The Mass is 5.68x10^26 KG.\n";
cout<<"The Radius is 120,536 km.\n";
double mass=5.68*pow(10,26);
double rad=120536;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 7:
cout<<"~~~~Uranus~~~~\n";
cout<<"The Mass is 8.683x10^25 KG.\n";
cout<<"The Radius is 51,118 KM.\n";
double mass= 8.683*pow(10,25);
double rad=51118;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 8:
cout<<"~~~~Neptune~~~~\n";
cout<<"The Mass is 1.0247x10^26 KG.\n";
cout<<"The Radius is 49,532 KM.\n";
double mass=1.0247*pow(10,26);
double rad=49532;
double volumeSphere= (4/3)*M_PI*pow(rad,3.0);
double density=mass/volumeSphere;
cout<<"The Density of Murcury is:: "<<density<<"\n";
double SurASphere= 4*M_PI*pow(rad,2.0);
cout<<"The Surface Area:: "<<SurASphere<<"\n";
break;}
{case 9:
cout << "\nType the Planet's name to add: ";
cin.get();
getline(cin, addPlanet);
PlanetList.push_back(addPlanet);
sort(PlanetList.begin(), PlanetList.end());
cin.clear();
cin.sync();
numberOfPlanets++;
cout << "\nGame successfully added.\n" << endl;
break;}
{case 10:
cout << "\nType the Planet's name to remove: ";
cin.get();
getline(cin, removePlanet);
PlanetIter = find(PlanetList.begin(), PlanetList.end(), removePlanet);
if (removePlanet == *PlanetIter) {
cout << "\nPlanet found!" << endl;
PlanetList.erase(PlanetIter);
numberOfPlanets--;
cout << "Title removed!\n" << endl;}
else{cout << "Title not found\n";}
break;}
{case 11:
set<string> sortedItems;
for(int i = 1; i <= 8; ++i)
{
string name;
cout << i << ". ";
cin >> name;
sortedItems.insert(name);}
for_each(sortedItems.begin(), sortedItems.end(), &print);
break;}
{case 12:
sort(PlanetList.begin(), PlanetList.end());
cout << "\nYou currently have " << numberOfPlanets << " Planets in your list.\n" << endl;
for (PlanetIter = PlanetList.begin(); PlanetIter != PlanetList.end(); ++PlanetIter) {
cout <<"\t"<< *PlanetIter << endl;}
break;}
{case 13:
cout << "End of Program.\n";
gameOn = false;
break;}
{default:
cout << "Not a Valid Choice. \n";
cout << "Choose again.\n";
cin >> choice;
break;}
}
}
return 0;
}
|