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
Choose the parts of the browser window.
8_murik_8 [283]

Answer:

The answer is "Title bar".

Explanation:

The title bar is located on top of the screen, its color blue, which is used in browsers. It has the function, that shows the title of the web page, that you currently viewing, and other choices were wrong, which can be described as follows:

  • Enter bar is the wrong option because it is not a part of the browser.
  • The back button is also known as a backspace key which is used to delete so thing, which is written by keyboard, that's why it is wrong.
  • The forward bar is used in pipe in a module that's why it's incorrect.

4 0
3 years ago
Explain what is the difference between a "Mode Switch" and a "Process Switch".
11111nata11111 [884]

Answer:

The main difference between mode switch and process switch is that mode switch changes the process privilege between modes like user mode and kernel mode while process switch changes the process state between different states. These processes then load into the main memory for the CPU to execute them.

Explanation:

8 0
3 years ago
Who programmed the UNIVAC computer and literally "debugged" the first computer?
marysya [2.9K]

Grace Hopper is the first
7 0
3 years ago
Read 2 more answers
Which of the following is not a good practice for effective Internet searches? Search for specific keywords that define your top
Bumek [7]

Answer:

Be general in your search query to get as many results possible

3 0
3 years ago
Intentional breeding for certain traits is known as
Arlecino [84]
<span>Artificial selection :)</span>
7 0
3 years ago
Read 2 more answers
Other questions:
  • 1. Which markup language adds the ability to use video without requiring the user to download add-ons?
    13·1 answer
  • Which method of encryption is based on physics principles?
    5·1 answer
  • What was the name of the system developed by Frederick Winslow Taylor, in which mass production is tied to the cultivation of ma
    10·1 answer
  • Explain why computer users should use the cloud?
    14·1 answer
  • Which signal types are represented by a continuous wave form?
    11·1 answer
  • With the help of what memory a computer can read as well as write or modify data
    14·2 answers
  • The last step on Kotter’s Eight-Step Change Model is to anchor the changes in corporate culture; to make anything stick, it must
    14·1 answer
  • Do you think cyber-bulling is more damaging, as damaging, or less damaging than in-person bullying? Why?
    11·2 answers
  • 1. (4 points) Write a function, called word_frequency, which takes a file name as a formal parameter and find the occurrence fre
    10·1 answer
  • What new information, strategies, or techniques have you learned that will increase your technology skills?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!