Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- #include<cmath>
- #include<math.h>
- #define PI 3.14
- using namespace std;
- void aos(){
- double side,aosquare;
- cout << "Input side: " << endl;
- cin >> side;
- if (side < 0){
- cout <<"ERROR! Please input a positive number!" << endl;
- aos();
- }
- aosquare = pow(side,2);
- cout << "Area of square is " << aosquare << "." << endl;
- }
- void por(){
- double l, w;
- cout << "Input length and width" << endl;
- cin >> l >> w;
- if (l < 0 && w < 0){
- cout <<"ERROR! Please input a positive number!" << endl;
- por();
- }
- double prectangle;
- prectangle = l * w;
- cout << "Perimeter of Rectangle: " << prectangle << endl;
- }
- void voc(){
- cout <<"Input r and h: " << endl;
- double r, h, vcylinder;
- cin >> r >> h;
- if(r < 0 && h < 0)
- {
- cout <<"ERROR! Please input a positive number!" << endl;
- voc();
- }
- vcylinder = (PI) * pow(r,2) * h;
- cout << "The volume of the cylinder is " << vcylinder << endl;
- }
- int main(){
- cout << "Developed by: Francis Gabriento" << endl;
- cout << "Station No.: 34" << endl;
- cout <<"MENU" << endl;
- double = choice;
- cout << "\t [1] Area of Square " << endl;
- cout <<"\t [2] Perimeter of a Rectangle" << endl;
- cout << "\t[3] Volume of a Cylinder " << endl;
- cout <<"Key in your choice: ";
- cin >> choice;
- switch(choice){
- case "1":
- aos();
- break;
- case "2":
- por();
- break;
- case "3":
- voc();
- break;
- default:
- cout << "You chose an Unknown Number!" << endl;
- cout <<"Please choose between [1], [2], and [3]" << endl << endl << endl;
- main();
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement