Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <cstdlib>
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- play:
- //Declarations
- double base, height;
- //Start
- cout << "\a" << endl;
- cout << "--Square Area Calculator (cm2)--" << endl;
- cout << "*******************************" << endl;
- system("pause");
- cout << "" << endl;
- //Inputs
- cout << "Base of square: ";
- cin >> base;
- cout << "Height of square: ";
- cin >> height;
- system("pause");
- //Result declarations
- double areaResult = base * height;
- double halfArea = areaResult / 2;
- //Display results
- cout << areaResult << "cm2" << endl;
- cout << "Half of the area is " << halfArea << "cm2" << endl;
- system("pause");
- retryOption:
- //Retry declaration variable
- string retryAnswer;
- //Retry option
- cout << "Want to calculate the area of another square? y=yes n=no: ";
- cin >> retryAnswer;
- if (retryAnswer == "y")
- {
- cout << "\a" << endl;
- system("cls");
- goto play;
- }
- else if (retryAnswer == "n")
- {
- exit;
- }
- else
- {
- cout << "Invalid answer, choose y or n." << endl;
- goto retryOption;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement