Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- cout << "Press 1 for cube"<<endl;
- cout << "Press 2 for cylinder"<<endl;
- cout << "Press 3 for sphere"<<endl;
- cout << "Press 4 for cone"<<endl;
- int option;
- float s,r,cube,cyl,ball,cone,h;
- float pi = 3.14;
- cin >> option;
- switch(option){
- case 1:
- cout << "Input s ";
- cin >> s;
- if(s<1){
- cout << "error";
- return 0;
- }
- cube = 6*s*s;
- cout << cube;
- break;
- case 2:
- cout << "Input r and h ";
- cin >> r;
- cin >> h;
- if(r<1 or h<1){
- cout << "error";
- return 0;
- }
- cyl = (2*pi*r*r)+(2*pi*r*h);
- cout << cyl;
- break;
- case 3:
- cout << "Input r";
- cin >> r;
- if(r<1){
- cout << "error";
- return 0;
- }
- ball = 4*pi*r*r;
- cout << ball;
- break;
- case 4:
- cout << "Input r and s";
- cin >> r;
- cin >> s;
- if(s<1 or r<1){
- cout << "error";
- return 0;
- }
- cone =(pi*r*s)+(pi*r*r);
- cout << cone;
- break;
- default:
- cout << "error";
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement