Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <math.h>
- #include <stdlib.h>
- using namespace std;
- int main(){
- /*
- START MAIN MENU
- */
- mainmenu:
- char menu;
- cout << "\t Main List Option\n\n";
- cout <<"\t [A] Perimeter\n";
- cout <<"\t [B] Area\n";
- cout <<"\t [C] Surface Area\n";
- cout <<"\t [D] Exit\n";
- cout <<"\t Enter Option: ";
- cin >> menu;
- // START MENU SWITCH
- switch(menu){
- case 'a':
- char permenu;
- perimeter:
- system("CLS");
- cout << "\t Perimeter \n\n";
- cout << "\t Geometric Figure\n\n";
- cout << "1] Square\n";
- cout << "2] Rectangle\n";
- cout << "3] Back to Main List of Options\n";
- cout << "\t Enter Option: ";
- // PERIMETER MENU
- permenu:
- cin >> permenu;
- switch (permenu){
- // SQUARE
- case '1':
- double side, total;
- system("CLS");
- cout << "\t Square \n";
- cout << "Enter measurement for one side of the square: ";
- cin >> side;
- cout << "inches\n";
- total = 4*side;
- cout << "The perimeter of a square with a side measurement \n" << "\t of " << side << "inches\n";
- cout << "\t is " << total <<"inches\n\n" ;
- cout << "Would you like to go back to Perimeter menu <Y/N>";
- // prompt
- char prompt;
- promptsquare:
- cin >> prompt;
- switch (prompt){
- case 'y':
- goto perimeter;
- case 'Y':
- goto perimeter;
- case 'n':
- exit(0);
- case 'N':
- exit(0);
- default :
- cout << "Please enter only <Y/N>\n";
- goto promptsquare;
- break;
- }
- // RECTANGLE
- case'2':
- double base,length;
- system("CLS");
- cout << "\t Rectangle \n";
- cout << "Enter length and base: ";
- cin >> length >> base;
- double rectotal;
- rectotal = 2*(length + base);
- cout << "The area of the rectangle is: " << rectotal << "\n";
- cout << "Would you like to go back to Perimeter menu <Y/N>";
- // prompt
- char promptrect;
- promptrect:
- cin >> promptrect;
- switch (promptrect){
- case 'y':
- goto perimeter;
- case 'Y':
- goto perimeter;
- case 'n':
- exit(0);
- case 'N':
- exit(0);
- default :
- cout << "Please enter only <Y/N>\n";
- goto promptrect;
- break;
- }
- // BACK TO MAIN MENU
- case'3':
- goto mainmenu;
- default:
- cout << "Please enter numbers 1-3. \n";
- goto permenu;
- }
- case 'b':
- char areamenu;
- area:
- system("CLS");
- cout << "\t Area \n\n";
- cout << "1] Triangle\n";
- cout << "2] Trapezoid\n";
- cout << "3] Circle\n";
- cout << "4] Back to Main List of Options\n";
- cout << "\t Enter Option: ";
- // START AREA MENU
- cin >> areamenu;
- switch(areamenu){
- //Triangle
- case '1':
- double base,height,tritotal;
- system("CLS");
- cout << "\t Triangle \n";
- cout << "Enter base and height: ";
- cin >> base >> height;
- tritotal = base*height/2;
- cout << "The area of the triangle is: " << tritotal << "\n";
- cout << "Would you like to go back to Area menu <Y/N>";
- // prompt
- char promptri;
- promptri:
- cin >> promptri;
- switch (promptri){
- case 'y':
- goto area;
- case 'Y':
- goto area;
- case 'n':
- exit(0);
- case 'N':
- exit(0);
- default :
- cout << "Please enter only <Y/N>\n";
- goto promptri;
- break;
- }
- case '2':
- double base1,base2,traptotal;
- system("CLS");
- cout << "\t Trapezoid \n";
- cout << "Enter base1, base2, and height: ";
- cin >> base1 >> base2 >> height;
- traptotal = (base1+base2)*height*1/2;
- cout << "The area of the trapezoid is: " << traptotal << "\n";
- cout << "Would you like to go back to Area menu <Y/N>";
- // prompt
- char promptrap;
- promptrap:
- cin >> promptrap;
- switch (promptrap){
- case 'y':
- goto area;
- case 'Y':
- goto area;
- case 'n':
- exit(0);
- case 'N':
- exit(0);
- default :
- cout << "Please enter only <Y/N>\n";
- goto promptrap;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement