Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // lab7.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //Michael MacRonald
- #include <iostream>
- using namespace std;
- int main()
- {
- int choice;
- double width;
- double length;
- double radius;
- double A;
- double B;
- double area;
- const double pi = 3.1415;
- cout << "Object area calculator menu\n";
- cout << "1. Square\n";
- cout << "2. Circle\n";
- cout << "3. Right Triangle\n";
- cout << "4. Quit\n";
- cin >> choice;
- if (choice == 1)
- {
- cout << "Enter Width\n";
- cin >> width;
- cout << "Enter length\n";
- cin >> length;
- area = width * length;
- cout << "Area of the square =" << area;
- }
- else if (choice == 2)
- {
- cout << "Enter radius of circle\n";
- cin >> radius;
- area = pi * radius * radius;
- cout << "Area of the circle =" << area;
- }
- else if (choice == 3)
- {
- cout << "Enter Length of leg A\n";
- cin >> A;
- cout << "Enter Lenth of leg B\n";
- cin >> B;
- area = (A * B) / 2;
- cout << "The area of the right triangle =\n" << area;
- }
- else if (choice == 4)
- {
- cout << "End of program";
- }
- else
- {
- cout << "The valid choices are 1 through 5\n";
- cout << "Please rerun the program and select one of those.";
- }
- return 0;
- }
- // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
- // Debug program: F5 or Debug > Start Debugging menu
- // Tips for Getting Started:
- // 1. Use the Solution Explorer window to add/manage files
- // 2. Use the Team Explorer window to connect to source control
- // 3. Use the Output window to see build output and other messages
- // 4. Use the Error List window to view errors
- // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
- // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement