Guest User

Untitled

a guest
Nov 28th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.61 KB | None | 0 0
  1. #include <iostream>
  2. #include<cstdlib>
  3. #include<stdio.h>
  4.  
  5. using namespace std;
  6.  
  7. /** Showing the introduction screen and the user maual... */
  8. void splash(void) {
  9.     cout << "   ********************************************************\n";
  10.     cout << "   *                                                      *\n";
  11.     cout << "   *            Velocity And Gear Programme ..            * \n";
  12.     cout << "   *         By:*****\n";
  13.     cout << "   *                                                      *\n";
  14.     cout << "   ********************************************************\n\n";
  15.  
  16.     cout<<endl ;
  17.     system ("PAUSE");
  18.     system ("cls");
  19.     cout << "****************************************************************\n";
  20.     cout << "*               USER MANUAL                                    *\n";
  21.     cout << "* FIRST :The programme will ask you to input the accelration   * \n";
  22.     cout << "* SECOND : The programme will ask you to input the time        *\n";
  23.     cout << "* THIRED : The programe will calcluate the velocity            *\n";
  24.     cout << "****************************************************************\n\n";
  25.  
  26.     system ("PAUSE");
  27.     system ("cls");
  28. }
  29. /** Showing the introduction screen and the user maual... */
  30.  
  31. double Velocity(double accel,double ntime)// to calcluate the Volcity
  32. {
  33.     double Velocity = accel*ntime;
  34.  
  35.     return Velocity;
  36. }
  37.  
  38.  
  39. int main ()
  40. {
  41.     double accel;
  42.     double ntime;
  43.     char choice;
  44.     char time[8];
  45.     double h=0, m=0, s=0;
  46.     splash();
  47.  
  48. do
  49.         {
  50.             cout<<"What was your Accelaration in (km/hour)  :  ";
  51.     cin>>accel;
  52.  
  53.     cout<<"\nWhat was your riding time in hr.min :  ";
  54.  
  55.     gets(time);
  56.  
  57.     h=(time[1]+(10*(time[0])))-528;
  58.     m=(time[4]+(10*(time[3])))-528;
  59.     s=(time[7]+(10*(time[6])))-528;
  60. //------>start if for the time..
  61. if(h>=0&&m>=0&&s>=0&&h<24&&m<=60&&s<=60)
  62.  
  63. {
  64.  
  65.  
  66.  
  67.     double ntime=h+m/60+s/3600;
  68.  
  69.     cout<<"/n your time is"<<ntime;
  70.  
  71.    //-------->the if for velocity..
  72.    Velocity(accel,ntime);
  73.         if (Velocity(accel,ntime)>=0 && Velocity(accel,ntime)<4)
  74.         {
  75.             cout<<"\nyour Velocity was    "<<Velocity<<endl;
  76.             cout<<" YOUR GEAR IS : 1";
  77.         }
  78.         else if (Velocity(accel,ntime) >=4 && Velocity(accel,ntime)<5)
  79.         {
  80.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  81.            cout<<" YOUR GEAR IS : 2";
  82.         }
  83.          else if (Velocity(accel,ntime) >=5 && Velocity(accel,ntime)<7)
  84.         {
  85.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  86.            cout<<" YOUR GEAR IS : 3";
  87.         }
  88.          else if (Velocity(accel,ntime) >=7 && Velocity(accel,ntime)<10)
  89.         {
  90.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  91.            cout<<" YOUR GEAR IS : 4";
  92.         }
  93.          else if (Velocity(accel,ntime) >=10 && Velocity(accel,ntime)<12)
  94.         {
  95.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  96.            cout<<" YOUR GEAR IS : 5";
  97.         }
  98.  
  99.          else if (Velocity(accel,ntime) >=12 && Velocity(accel,ntime)<15)
  100.         {
  101.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  102.            cout<<" YOUR GEAR IS : 6";
  103.         }
  104.          else if (Velocity(accel,ntime) >=15 && Velocity(accel,ntime)<17)
  105.         {
  106.             cout<<"\nyour volcity was    "<<Velocity(accel,ntime)<<endl;
  107.            cout<<" YOUR GEAR IS : 7";
  108.         }
  109.          else if (Velocity(accel,ntime) >=17 && Velocity(accel,ntime)<21)
  110.         {
  111.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  112.            cout<<" YOUR GEAR IS : 8";
  113.         }
  114.          else if (Velocity(accel,ntime) >=21 && Velocity(accel,ntime)<24)
  115.         {
  116.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  117.            cout<<" YOUR GEAR IS : 9";
  118.         }
  119.          else if (Velocity(accel,ntime) >=24 && Velocity(accel,ntime)<28)
  120.         {
  121.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  122.            cout<<" YOUR GEAR IS : 10";
  123.         }
  124.          else if (Velocity(accel,ntime) >=28 && Velocity(accel,ntime)<35)
  125.         {
  126.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  127.            cout<<" YOUR GEAR IS : 11";
  128.         }
  129.          else if (Velocity(accel,ntime) >=35 && Velocity(accel,ntime)<40)
  130.         {
  131.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  132.            cout<<" YOUR GEAR IS : 12";
  133.         }
  134.          else if (Velocity(accel,ntime) >=40 && Velocity(accel,ntime)<48)
  135.         {
  136.             cout<<"\nyour Velocity was    "<<Velocity(accel,ntime)<<endl;
  137.            cout<<" YOUR GEAR IS : 13";
  138.         }
  139.          else if (Velocity(accel,ntime) >=48 && Velocity(accel,ntime)<55)
  140.         {
  141.             cout<<"\nyour Velocity was   "<<Velocity(accel,ntime)<<endl;
  142.            cout<<"YOUR GEAR IS : 14";
  143.         }
  144.          else if (Velocity(accel,ntime) >=55 && Velocity(accel,ntime)<100)
  145.         {
  146.            cout<<"\nYour Velocity was    "<<Velocity(accel,ntime)<<endl;
  147.            cout<<"YOUR GEAR IS : 15";
  148.         }
  149.          else if (Velocity(accel,ntime) >100 )
  150.         {
  151.            cout<<" The Maximmum Volcity that the programme can calcluate is 100 km/hr... SORRY!";
  152.         }
  153.         else if (Velocity(accel,ntime) <0 )
  154.         {
  155.            cout<<" ERROR!!";
  156.         }
  157.         }
  158. //------->end of if velocity
  159.  
  160. else// else for if time
  161. {
  162. cout<< "Your time is Invalid";
  163. }
  164.         cout<<"\n\nDo you wish to continue? (Y/N)";
  165.         cin>>choice;
  166.         cout<<"\n\n\n----------------------------\n\n\n";
  167.         system("cls");}
  168.        while(choice == 'Y'|| choice == 'y');
  169. return 0;
  170. }
  171.  
  172.  
Advertisement
Add Comment
Please, Sign In to add comment