Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  final11
Language: C/C++
Code:
#include <iostream>
#include<fstream>
//#include<conio.h>
#include <stdlib.h>

using namespace std;
int  getwhatyouwant();
//main function
int 

main() {
    int whatyouwant;
//getwhatyouwant();
while (whatyouwant<=7) {
whatyouwant=getwhatyouwant();}

}

//  getwhatyouwantfunction
int  

getwhatyouwant() {
    int choice;
cout <<"welcome to your ph calcu"<<endl;
cout <<"1-acceleration"<<endl;
cout << "2-momentum"<<endl;
cout << "3-force"<<endl;
cout << "4-speed"<<endl;
cout << "5-ke"<<endl;
cout <<"6-pe"<<endl;
cout <<"7-quit program"<<endl;
cout << "enter your number"<<endl;
cin>>choice;


   int x,y,z;



        switch(choice)
            case 1:     {
               cout<<"acceleration"<<endl;
               cout<<"enter the mass"<<endl;
               cin>>x;
               cout<< "enter the force"<<endl;
               cin>>y;
               cout<<"acceleration is: "<<x*y<<"kg m/s*s"<<endl;
               break;
    
             }
  //switch(nh)
   //break;
  // 

//getwhatyouwant();
  
        switch(choice)
            case 2:  {
                cout << "momentum"<<endl;
                cout << "enter the mass"<<endl;
                cin>>x;
                cout << "enter the velocity"<<endl;
                cin>>y;
                cout << "the momentum is: "<<x*y<<"kgm/s*s"<<endl;
                break;

              }
              
        switch(choice)
            case 3:  {
                cout<<"speed"<<endl;
                cout<< "enter the distance"<<endl;
                cin>>x;
                cout<<"enter the time"<<endl;
                cin>>y;
                cout<<"the speed is"<<x/y<<"m/s"<<endl;
                break;

        }
              
        switch(choice)
            case 4: {
               cout << "force"<<endl;
               cout << "enter the mass"<<endl;
               cin>>x;
               cout<<"enter the acceleration"<<endl;
               cin>>y;
               cout << "the force is: "<< x*y<<"N"<<endl;
               break;
             }
             
        switch(choice)
            case 5: {
                cout << "for ke"<<endl;
                cout << "enter the mass"<<endl;
                cin>>x;
                cout<<"enter the velocity"<<endl;
                cin>>y;
                cout<< "the ke is: "<< 0.5*x*y<<"J"<<endl;
                break;
              }
 

             
        switch(choice)
            case 6: {
                  cout<<"for pe"<<endl;
                  cout<<"enter the mass"<<endl;
                  cin>>x;
                  cout<<"enter the height"<<endl;
                  cin>>y;
                  cout<<"enter the gravity"<<endl;
                  cin>>z;
                  cout<<"the pe is: "<<x*y*z<<"J"<<endl;
                  break;
               }
               
        switch(choice)
            case 7: {
                 //exit(EXIT_SUCCESS);
                 cout<<"You are exiting."<<endl;
                 exit(EXIT_SUCCESS);
               }
  

             
 // getch();   
 }


//getch();
//}     
Comments: