Advertisement
GarikK

Untitled

Jan 24th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. // HomeWork_2
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. void Speed()
  6. {
  7.     float distance,
  8.           time,
  9.           speed; // creating variable
  10.           cout << "Please? enter a distance - km\n";//asking user to enter a distance
  11.           cin >> distance;//saving user's number to variable distance
  12.           cout << "Please? enter the time - \n";
  13.           cin >> time;//saving user's number of time to variable time
  14.           speed = distance / time;//decision at what speed you need to go
  15.           cout << "You need to drive at a speed - " << speed << "km\/hour\n";
  16. }
  17.  
  18. void cost()
  19. {
  20.     float begin_hours, begin_min, begin_sec; //creating variables
  21.     float end_hours, end_min, end_sec;
  22.     cout << "Enter the begin time  h,min,sec" << endl;//asking the start of the conversation
  23.     cin >> begin_hours >> begin_min >> begin_sec;
  24.     cout << "Enter the end time  h,min,sec" << endl;//asking th end of the conversation
  25.     cin >> end_hours >> end_min >> end_sec;
  26.     float begin_tmp = begin_hours * 60 + begin_min + begin_sec / 60;
  27.     float end_tmp = end_hours * 60 + end_min + end_sec / 60;
  28.     float tmp = end_tmp - begin_tmp;
  29.     cout << "cost of call " << tmp * 0.3 << " UAH" << endl;
  30. }
  31.  
  32. void price()
  33. {
  34.     float distance, gasMileage, gas92, gas95, gas100;//creating variables
  35.     cout << "Please, enter a distance \n";//asking for a distance
  36.     cin >> distance;
  37.     cout << "Please, enter a gas mileage per 100 km \n";//asking for a gas mileage for 100 km
  38.     cin >> gasMileage;
  39.     cout << "Please, enter the price of gasoline 92  \n";//asking for a price
  40.     cin >> gas92;
  41.     cout << "Please, enter the price of gasoline 95  \n";//asking for a price
  42.     cin >> gas95;
  43.     cout << "Please, enter the price of gasoline 100  \n";//asking for a price
  44.     cin >> gas100;
  45.     float   cost92 = gas92 * gasMileage,
  46.             cost95 = gas95 * gasMileage,
  47.             cost100 = gas100 * gasMileage;
  48.     cout << "\n\t\t Price table \n" << "Gasoline 92\t" << "Gasoline 95\t" << "Gasoline 100 \n" << cost92 << "$\t\t" << cost95 << "$\t\t" << cost100 << "$\n\n\n";//show the price table
  49. }
  50.  
  51. int main()
  52. {
  53.     //Task: What speed do we need to get to aeroport
  54.     Speed();
  55.     //Task2: The cost of the conversation
  56.     cost();
  57.     //Task3: The price table
  58.     price();
  59.     system("pause");
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement