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
1. What is the Internet?
3241004551 [841]
A place to watch daisy Taylor vids
8 0
3 years ago
Read 2 more answers
Write one line of code to print animals, an array of Animal objects.
oksian1 [2.3K]

Answer:

console.log(Animal);

Explanation:

The statement written above prints the array Animal which contains objects.There are two to three ways to print the array Animal in javascript. One of the method is written in the answer it prints the arrays in the console of the browser.

You can go to the console by pressing F12 and then clicking on the console.

Other methods to print are

  1. Simple write Animal after defining the array.
  2. Use alert.
  3. document.write()
7 0
3 years ago
How do you get a free ps4
KatRina [158]

Answer:

By having very good luck and winning it in a giveaway!!!

4 0
3 years ago
Read 2 more answers
Q.N.2. Write T for true statement and 'F' for the false one: with a) Monitor is called visual display unit. b) IPO is the basic
Svetradugi [14.3K]

Answer:

a. t

B.f

c.f

d.f

e.f

f.f

g. f

4 0
3 years ago
A member of your team wants to add some funny pictures that he took during the company party to lighten the mood at the beginnin
san4es73 [151]
No, because they are personal photos taken of an event that was not copyrighted. If the event was copyrighted then they would but if not then no.
7 0
3 years ago
Read 2 more answers
Other questions:
  • For local travel addresses and street names should be
    14·1 answer
  • Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with a
    13·1 answer
  • Give the difference betewen recursion and interation in C. Sight what are the advantages and their disadvantages?
    7·1 answer
  • What is the safest way to install a new flash drive
    7·2 answers
  • Among the following, which is the best protection against ransomware?
    8·1 answer
  • The security administrator for Corp.com. You are explaining to your CIO the value of credentialed scanning over non-credentialed
    15·2 answers
  • Lin wants to play an online game with her friends. She read the description of the game and knows it contains several features w
    12·1 answer
  • If C2=20 and D2=10 what is the result of the function = mathcal I F(C2=D2,^ prime prime Ful "Open")?
    11·1 answer
  • In a relational database, information is organized into tables in which each row represents a(n ) ________. Group of answer choi
    6·1 answer
  • What are some of the most common obstacles in video games?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!