Edit: I figured out how to do everything and it works, but my area for the triangle part keeps giving me values of 0 for every answer.
The program is a Geometry calculator, works perfectly.
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int loop=1;
int choice;
while (loop==1)
{
system("CLS");
cout << "::Geometry Calculator::\n\n"
<< "1. Area of a Circle\n"
<< "2. Area of a Triangle\n"
<< "3. Exit\n\n";
cin >> choice;
switch(choice)
{
case 1:
system("CLS");
double pi, radius, area;
cout << "::Area of a Circle::\n\n"
<< "Enter your radius: ";
cin >> radius;
pi = 3.14159;
area = pi * (radius*radius);
cout << "The area of the circle is " << area << "." << endl;
system("PAUSE");
}
switch(choice)
{
case 2:
if(choice==2)
system("CLS");
int base, height, a2;
cout << "::Area of a Triangle::\n\n"
<< "Enter your base: ";
cin >> base;
cout << "Enter your height: ";
cin >> height;
a2 = 1/2 * base * height;
cout << "Your result is " << a2 << "." << endl;
system("PAUSE");
}
switch(choice)
{
case 3:
if(choice==3)
system("CLS");
This may not always be accurate as base and height are both declared as type int and the magic number 2 is written as an int so if there is a remainder it will be lopped.