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
IblMessage.txt=welcome to fiji.what is the error in the coding and what type of error is it?(explain)​
spin [16.1K]

Answer:

The correct syntax (assuming WinForms) is

lblMessage.Text = "Welcome to fiji";

The given statement fails to follow the syntax of literal strings, which should be in quotation marks. (depending on the framework and programming language, the txt property may also be incorrect, as well as the missing semi-colon).

8 0
3 years ago
Q: Why can't I log in to Brainly
algol13

Answer:

yes you are probably on a school Chromebook

Explanation:

5 0
2 years ago
22. Which of the following device will you require to hear music on
Anon25 [30]

Answer: None

Explanation:

I don’t even knew these.

4 0
3 years ago
A(n) ________ event is an alert that is generated when the gossip traffic enables a platform to conclude that an attack is under
Allisa [31]

Answer:

B. DDI

Explanation:

A(n) DDI event is an alert that is produce or invoke when the gossip traffic allow a platform to conclude that an attack or potential attack is under way.

A device driver is a computer program that operates or controls a particular type of device that is attached to a computer system.

A driver provides or supply a software interface to hardware devices which enable the operating systems and other computer programs to access hardware functions without needing to know the exact details in respect of the hardware being used.

DDI means Device Driver Interface

A driver relate or communicate with the device via the computer bus or communications subsystem to which the hardware is connected. Whenever a calling program invokes a routine in the driver, the driver will subsequently transmit commands to the device.

7 0
2 years ago
1. Where did the Industrial Revolution start and why did it begin there?​
Bingel [31]

Answer:

The first Industrial Revolution began in Great Britain in the mid-to-late 1700s, when innovation led to goods being produced in large quantities due to machine manufacturing.

This process began in Britain in the 18th century and from there spread to other parts of the world. Although used earlier by French writers, the term Industrial Revolution was first popularized by the English economic historian Arnold Toynbee (1852–83) to describe Britain's economic development from 1760 to 1840.

8 0
2 years ago
Read 2 more answers
Other questions:
  • It is generally safe to provide your social security number to
    7·2 answers
  • Canadian Tire is one of Canada’s largest companies. They operate four large distribution centers service over 470 tire retail ou
    5·1 answer
  • When storage devices write data, instructions, and information on storage media, they are creating output. what best describes t
    10·1 answer
  • Technological uncertainty:
    15·1 answer
  • Adrian wants to run a digital movie clip that his friend shared with him through email. His system has 2 GB of RAM and 20 GB of
    15·1 answer
  • ______ is the ability of a system to do more than one thing at a time. A. Multibusing c. online processing b. Multiprocessing d.
    13·1 answer
  • The rock cycle _____.
    14·1 answer
  • 1. Which sentence best expresses the main idea
    12·1 answer
  • Java can be procedural or object-oriented when it comes to programming. What is the difference between procedural and OOP?​
    13·1 answer
  • It refers to the story or events in which the film revolves.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!