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
|
#include "stdafx.h"
#include <math.h>
#include <iostream>
#include <vector>
#include <conio.h>
using namespace std;
void circle ();
void triangle ();
void rectangle ();
int main()
{
int menuChoice = 0;
cout << "Do you require:-" << endl;
cout << "1. Circle" << endl;
cout << "2. Triangle" << endl;
cout << "3. Rectangle" << endl;
cout << "4. Quit" << endl;
cout <<" " << endl;
cin >> menuChoice;
cout << " " << endl;
if (menuChoice == 1)
{
circle ();
}
else if (menuChoice == 2)
{
triangle ();
}
else if (menuChoice == 3)
{
rectangle ();
}
else if (menuChoice == 4)
{
cout << "Goodbye" << endl << endl;
}
// CIRCLE!!!
void cicrle ()
{
double circumference = 0, area = 0, diameter = 0, radius = 0, pi = 0, menuChoice1 = 0;
cout << "Please choose an option: " << endl;
cout << "1. Circumference" << endl;
cout << "2. Area" << endl;
cout << " " << endl;
cin >> menuChoice1;
cout << " " << endl;
if ( menuChoice1 == 1 )
{
cout << "Please enter the diameter of the circle: " << endl;
cin >> diameter;
cout << " " << endl;
cout << "Please enter the value of Pi you wish to use: " << endl;
cin >> pi;
cout << " " << endl;
circumference = diameter*pi;
cout << "The circumference is: " << endl;
cout << circumference << endl;
cout << " " << endl;
}
else if ( menuChoice1 == 2 )
{
cout << "Please enter the radius (half the diameter) of the circle: " << endl;
cin >> radius;
cout << " " << endl;
cout << "Please enter the value of Pi you wish to use: " << endl;
cin >> pi;
cout << " " << endl;
radius = radius * radius;
area = radius * pi;
cout << "The area is: " << endl;
cout << area << endl;
cout << " " << endl;
}
}
//TRIANGLE
void triangle ()
{
double perimeter = 0, area = 0, sideA = 0, sideB = 0, sideC = 0, height = 0, base = 0, menuChoice2 = 0;
cout << "Please choose an option: " << endl;
cout << "1. Perimeter" << endl;
cout << "2. Area" << endl;
cout << " " << endl;
cin >> menuChoice2;
cout << " " << endl;
if ( menuChoice2 == 1 )
{
cout << "Please enter the length of side A:" << endl;
cin >> sideA;
cout << " " << endl;
cout << "Please enter the length of side B:" << endl;
cin >> sideB;
cout << " " << endl;
cout << "Please enter the length of side C:" << endl;
cin >> sideC;
cout << " " << endl;
perimeter = sideA + sideB + sideC;
cout << "The perimeter of the triangle is:" << endl;
cout << perimeter << endl;
cout << " " << endl;
}
else if ( menuChoice2 == 2 )
{
cout << "Please enter the perpendicular height of the rectangle:" << endl;
cin >> height;
cout << " " << endl;
cout << "Please enter the length of the triangles base:" << endl;
cin >> base;
cout << " " << endl;
base = base/2;
area = base*height;
cout << "The area is:" << endl;
cout << area << endl;
cout << " " << endl;
}
}
//RECTANGLE
void rectangle ()
{
double perimeter = 0, area = 0, height = 0, width = 0, menuChoice3 = 0;
cout << "Please choose an option:" << endl;
cout << "1. Perimeter" << endl;
cout << "2. Area" << endl;
cout << " " << endl;
cin >> menuChoice3;
cout << " " << endl;
if ( menuChoice3 == 1 )
{
cout << "Please enter the height of the rectangle:" << endl;
cin >> height;
cout << " " << endl;
cout << "Please enter the width of the rectangle:" << endl;
cin >> width;
cout << " " << endl;
perimeter = height + height + width + width;
cout << "The perimeter is:" << endl;
cout << perimeter << endl;
cout << " " << endl;
}
else if ( menuChoice3 == 2 )
{
cout << "Please enter the height of the rectangle:" << endl;
cin >> height;
cout << " " << endl;
cout << "Please enter the width of the rectangle:" << endl;
cin >> width;
cout << " " << endl;
area = height*width;
cout << "The area is:" << endl;
cout << area << endl;
cout << " " << endl;
}
}
}
| |