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
|
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int main()
{
int option;
int y;
int n;
double number1;
double number2;
double pi = 3.14;
double area1;
double area;
cout << "Greetings. I am The Sage, what game shall we play today?" << endl;
for (;;)
{
cout << endl << "Choose your path, choose your game. \n"
<< endl
<< "1 Calculate the Area of an Ellipse \n"
<< "2 Calculate the Area of a Sector \n"
<< "3 Calculate the Area of a Triangle \n"
<< "4 Calculate the Area of a Rhombus \n"
<< "5 Calculate the Area of a Pentagon \n"
<< endl
<< "You may also read more about the Sage. \n"
<< "6 About the Sage \n"
<< "7 Leave \n"
<< endl
<< "What will you play? \n"
<< endl;
cin >> option;
switch (option)
{
case 1: cout << endl << "I am going to calculate the area of an Ellipse. \n";
cout << "Enter your first number. \n";
cin >> number1;
while (number1==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number1;
}
cout << "Now, my friend, enter the second number. \n";
cin >> number2;
while (number2==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number2;
}
area = pi * number1 * number2;
cout << "The area of ellipse is " << area;
break;
case 2: cout << endl << "I am going to calculate the area of an Sector. \n";
cout << "Enter your first radius. \n";
cin >> number1;
while (number1==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number1;
}
cout << "Now, my friend, enter the angle. \n";
cin >> number2;
while (number2==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number2;
}
area = pi * pow(number1, 2) * number2 / 360;
cout << "The area of sector is " << area;
break;
case 3: cout << endl << "I am going to calculate the area of an Triangle. \n";
cout << "Enter your first base of the triangle. \n";
cin >> number1;
while (number1==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number1;
}
cout << "Now, my friend, enter the height. \n";
cin >> number2;
while (number2==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number2;
}
area = number1 * number2 / 2;
cout << "The area of triangle is " << area;
break;
case 4: cout << endl << "I am going to calculate the area of a rhombus. \n";
cout << "Enter your length. \n";
cin >> number1;
while (number1==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number1;
}
cout << "Now, my friend, enter width. \n";
cin >> number2;
while (number2==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number2;
}
area = number1 * number2;
cout << "The area of rhombus is " << area;
break;
case 5:
cout << endl << "I am going to calculate the area of a Pentagon. \n";
cout << "We will split the polygon into five pieces. \n";
cout << "Enter your first base of the triangle. \n";
cin >> number1;
while (number1==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number1;
}
cout << "Now, my friend, enter the height. \n";
cin >> number2;
while (number2==0)
{
cout << "You CANNOT use a zero." << endl;
cout << "Enter another number!....My friend." << endl;
cin >> number2;
}
area1 = number1 * number2 / 2;
cout << "The area of triangle is " << area1 << endl;
cout << "Now, we shall multiply by Five. \n";
area = area1 * 5;
cout << "Your area is, " << area << endl << endl;
break;
case 6: cout << endl << "I...am the sage. \n";
cout << "I was once a mere student of Computer science \n";
cout << "but after a computer accident, I had to recuperate. \n";
cout << "They could rebuild me. They had the technology. \n";
cout << "They had the capabilty to make me better... \n";
cout << "Faster.... \n";
cout << "Stronger. \n";
break;
case 7: cout << endl << "Are you ready to leave, my friend? So soon? \n";
cout << "y or n ? \n";
cin >> option;
if(option == n)
{
break;
if(option == y)
{
cout << "We will meet again, I am sure.";
}
}
}
}
return 0;
system(pause);
}
|