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 <string>
#include <iomanip>
#include <vector>
using namespace std;
double SLength, SWidth, SArea, RLength, RWidth, RArea, radius, CArea, base, height, TArea, total_area, labor, carpet, total, taxcost;
const double pi = 3.14;
const double cost = 2.45;
const double tax = .085;
vector<int> choices;
void AreaSquare() //creating an equation to be called to in my switch for fahrenheit conversion
{
SArea = pow(SLength,2.0);
}
void AreaRectangle() //creating an equation to be called to in my switch for fahrenheit conversion
{
RArea = (RWidth * RLength);
}
void AreaCircle() //creating an equation to be called to in my switch for fahrenheit conversion
{
CArea = pi * pow(radius,2.0);
}
void AreaTriangle() //creating an equation to be called to in my switch for fahrenheit conversion
{
TArea = 0.5 * base * height;
}
int main()
{
unsigned short choice;
do
{
cout << "Please choose from the following: " << "\n";
cout << "1: Square"<< "\n";
cout << "2: Rectangle"<< "\n";
cout << "3: Circle"<< "\n";
cout << "4: Triangle"<< "\n";
cout << "5: Total Area"<< "\n";
cout << "0: To Exit the Program"<< "\n";
cin >> choice;
system ("cls");
switch (choice)
{
case 1:
cout << "Please enter the Length: ";
cin >> SLength;
AreaSquare();
cout << "The area of the Square is " << SArea << "\n";
total_area += SArea;
system ("pause"); // pauses the program
system ("cls"); //clears the screen
break;
case 2:
cout << "Please enter the Length: ";
cin >> RLength;
cout << "Please enter the Width: ";
cin >> RWidth;
AreaRectangle();
cout << "The area of the Rectangle is " << RArea<< "\n";
total_area += RArea;
system ("pause"); // pauses the program
system ("cls"); //clears the screen
break;
case 3:
cout << "Please enter the Radius of the Circle: ";
cin >> radius;
AreaCircle();
cout << "The area of the Circle is: " << CArea<< "\n";
total_area += CArea;
system ("pause"); // pauses the program
system ("cls"); //clears the screen
break;
case 4:
cout << "Please enter the base of the Triangle: ";
cin >> base;
cout << "Please enter the height of the Triangle: ";
cin >> height;
AreaTriangle();
cout << "The area of the Triangle is " << TArea << "\n";
total_area += TArea;
system ("pause"); // pauses the program
system ("cls"); //clears the screen
break;
case 5:
for ( size_t i = 0; i < choices.size(); i++ )
{
if ( choices[i] == 1 )
{
cout << "Shape: Square" << "\n";
cout << "Length: " << SLength << "\n";
cout << "Area: " << SArea << "Square Feet" << "\n";
}
else if ( choices[i] == 2 )
{
cout << "Shape: Rectangle" << "\n";
cout << "Length: " << RLength << "\n";
cout << "Width: " << RWidth << "\n";
cout << "Area: " << RArea << "Square Feet"<< "\n";
}
else if ( choices[i] == 3 )
{
cout << "Shape: Circle" << "\n";
cout << "Radius: " << radius << "\n";
cout << "Area: " << CArea << "Square Feet" << "\n";
}
else if ( choices[i] == 4 )
{
cout << "Shape: Triangle" << "\n";
cout << "Base: " << base << "\n";
cout << "Height: " << height << "\n";
cout << "Area: " << TArea << "Square Feet" << "\n";
}
}
labor = (total_area / 50) * 35.72;
carpet = (total_area * 2.45);
taxcost = (labor + carpet) * tax;
total = (labor + carpet + taxcost) ;
cout << fixed << showpoint << setprecision(2);
cout << "Total area: $" << total_area << " Square Feet " << "\n";
cout << "Carpet Cost: $" << carpet << "\n";
cout << "Labor cost: $" << labor << "\n";
cout << "Tax: $" << taxcost << "\n";
cout << "Total Cost: $" << total << "\n";
case 0: //case in case user selects 0 the program will exit
cout << "Program is terminating..."<< endl;
system ("pause");
return 0;
break; //causes the prgram to execute the next statement outside the switch
default: //the third case incase the user enters an invalid option
cout << "That is not an option!" << endl;
cout << "Please try again." << endl;
cout << "\n" << endl;
cout << "\n" << endl;
cout << "\n" << endl;
system ("pause"); // pauses the program
system ("cls"); //clears the screen
break; //causes the program to execute the next statement outside the switch
}
} while (choice != 0);
}
|