Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // HomeWork_2
- #include <iostream>
- using namespace std;
- void Speed()
- {
- float distance,
- time,
- speed; // creating variable
- cout << "Please? enter a distance - km\n";//asking user to enter a distance
- cin >> distance;//saving user's number to variable distance
- cout << "Please? enter the time - \n";
- cin >> time;//saving user's number of time to variable time
- speed = distance / time;//decision at what speed you need to go
- cout << "You need to drive at a speed - " << speed << "km\/hour\n";
- }
- void cost()
- {
- float begin_hours, begin_min, begin_sec; //creating variables
- float end_hours, end_min, end_sec;
- cout << "Enter the begin time h,min,sec" << endl;//asking the start of the conversation
- cin >> begin_hours >> begin_min >> begin_sec;
- cout << "Enter the end time h,min,sec" << endl;//asking th end of the conversation
- cin >> end_hours >> end_min >> end_sec;
- float begin_tmp = begin_hours * 60 + begin_min + begin_sec / 60;
- float end_tmp = end_hours * 60 + end_min + end_sec / 60;
- float tmp = end_tmp - begin_tmp;
- cout << "cost of call " << tmp * 0.3 << " UAH" << endl;
- }
- void price()
- {
- float distance, gasMileage, gas92, gas95, gas100;//creating variables
- cout << "Please, enter a distance \n";//asking for a distance
- cin >> distance;
- cout << "Please, enter a gas mileage per 100 km \n";//asking for a gas mileage for 100 km
- cin >> gasMileage;
- cout << "Please, enter the price of gasoline 92 \n";//asking for a price
- cin >> gas92;
- cout << "Please, enter the price of gasoline 95 \n";//asking for a price
- cin >> gas95;
- cout << "Please, enter the price of gasoline 100 \n";//asking for a price
- cin >> gas100;
- float cost92 = gas92 * gasMileage,
- cost95 = gas95 * gasMileage,
- cost100 = gas100 * gasMileage;
- 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
- }
- int main()
- {
- //Task: What speed do we need to get to aeroport
- Speed();
- //Task2: The cost of the conversation
- cost();
- //Task3: The price table
- price();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement