1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Crank
3 years ago
9

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g

as cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements.
Computers and Technology
1 answer:
zepelin [54]3 years ago
8 0

Answer:

Explanation:

The following is written in C++ and asks the user for inputs in both miles/gallon and dollars/gallon and then calculates the gas cost for the requested mileages using the input values

#include <iostream>

#include <iomanip>

using namespace std;

int main () {

   // distance in miles

   float distance1 = 20.0, distance2 = 75.0, distance3 = 500.0;

   float miles_gallon, dollars_gallon;

   cout << "Enter cars miles/gallon: "; cin >> miles_gallon;

   cout << "Enter cars dollars/gallon: "; cin >> dollars_gallon;

   cout << "the gas cost for " << distance1 << " miles is " << fixed << setprecision(2) << (float) dollars_gallon * distance1 / miles_gallon << "$\n";

   cout << "the gas cost for " << distance2 << " miles is " << fixed << setprecision(2) << (float) dollars_gallon * distance2 / miles_gallon << "$\n";

   cout << "the gas cost for " << distance3 << " miles is " << fixed << setprecision(2) << (float) dollars_gallon * distance3 / miles_gallon << "$\n";

   return 0;

}

You might be interested in
What do people do when they navigate using GPS
Debora [2.8K]

Answer:

they use  it when they are driving and when they dont know where they are doing

Explanation:

7 0
3 years ago
Read 2 more answers
State the difference between a monitor and a television​
Maurinko [17]
The size of a monitor is not much larger. As these are used from a specific distance, it would be so inconvenient if a monitor size is too big.
7 0
2 years ago
Read 2 more answers
Pleeeese help me for these questions
geniusboy [140]

1 Account

2 online

3 access

4 password

5 internet

6 email

4 0
3 years ago
I'll give brainlist to right answers
xeze [42]
I think it’s number 1. Check the answer first.
5 0
3 years ago
Advatages and disadvantages of power-concentrated train​
allochka39001 [22]

Answer:

1. Safety:

2. Cheap:

3. Increases Employment:

4. Bulk Quantity:

The Disadvantages of Rail Transport are as Follows:

1. Loss of Goods:

2. Unsafe for Fragile Items:

3. Late Bookings:

4. Unsuitable for Short Distances:

5. Unsuitable for Rural Areas:

Explanation:1. Safety:

Transportation by the means of railway ensures safety for the desired goods because unlike the road transports a train only stops at a desired station instead of the will of the driver. In case of road transports for example, the drivers can at any point of time decide to rest or stop for tea, refreshments, lunch or dinner.

2. Cheap:

Railway transport any day is cheaper as compared to air transport. As a matter of fact, railway transport is even cheaper than road transport because of the reason that goods in bulk quantities are carried from a desired destination to the other. In cases of road transport for instance, less goods as compared to road transport can be carried.

3. Increases Employment:

Railway transport helps people to carry cheap products from a place to another and sell them at high prices. As a result of this, a number of people who are unemployed find a source of their daily bread.

4. Bulk Quantity:

ADVERTISEMENTS:

Because railway transportation is cheaper as compared to air and road transport, goods can be carried in bulk quantities as a result of which a lot of time is saved.

It is true that as compared to air transport and road transport, rail transport is easier and cheaper but still it has a few disadvantages.

The Disadvantages of Rail Transport are as Follows:

1. Loss of Goods:

Because goods in bulk quantities are carried chances of goods getting lost are high in case of railway transport as compared to air and road transport.

2. Unsafe for Fragile Items:

Railway transportation is particularly unsafe for carrying fragile items like glass because these items can easily break at times when a train halts unexpectedly of when the train is speeding up at times.

3. Late Bookings:

ADVERTISEMENTS:

Because railway is the cheapest medium of transport, it is hard to find suitable bookings for the transportation of your goods. Railway transport is not suitable in cases of emergency.

4. Unsuitable for Short Distances:

Railway transport is unsuitable for carrying goods at shorter distances; road transport is most suitable in this case.

5. Unsuitable for Rural Areas:

Proper railway system is not build up in the Indian villages as a result of which railway transport is unsuitable in the villages of India. Whatever be the disadvantages of railway transport it was, it is and it will always be the safest and the best means for the transportation of goods.

5 0
3 years ago
Other questions:
  • Tower defense is included under which genre of game
    15·2 answers
  • What can be entered in a search box to find data? data size a name relevance purpose
    5·2 answers
  • Which of these sites would need additional investigation to check for reliability?
    8·2 answers
  • What time does walmart deposit paychecks?
    5·1 answer
  • Explain the components of Information System?​
    13·1 answer
  • Kyle wants to access his school’s home page. How can he do this?
    8·2 answers
  • You can count on everything online to be 100% accurate. <br> A. FALSE <br> B. TRUE
    11·2 answers
  • You make an online purchase of a hooded sweatshirt with the logo of the Dallas Cowboys. The next time you log on, your screen ha
    13·1 answer
  • What is Data rate?<br> What is BAUD RATE?<br> What is bandwidth?
    8·1 answer
  • Write the functions of F1 to F12 on the keyboard​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!