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
Burka [1]
3 years ago
7

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 as follows: System.out.printf("%.2f", yourValue); The output ends with a newline.
Computers and Technology
2 answers:
Tatiana [17]3 years ago
4 0

Answer:

const double gasDollarPerGallon = 20 ;

float calCost( double milesPerGallon ) {

   double costPerGallon = milesPerGallon / gasDollarPerGallon;

   System.out.printf ("%.2f/n", &costPerGallon);

int main ( ) {

   scanf ("%2f", &gasDollarPerGallon) ;

   calCost( 20 );

   calCost( 75 );

   calCost( 500 );

Explanation:

The C source code above gets the user input of the gas dollar per gallon from the command prompt and divides the miles per gallon variable in the function call to get the cost of gas for the range of miles. It is also print out as a double with two places.

kiruha [24]3 years ago
4 0

Answer:

def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):

  gallon_used = driven_miles / miles_per_gallon

  cost = gallon_used * dollars_per_gallon  

  return cost  

miles_per_gallon = float(input(""))

dollars_per_gallon = float(input(""))

cost1 = driving_cost(10, miles_per_gallon, dollars_per_gallon)

cost2 = driving_cost(50, miles_per_gallon, dollars_per_gallon)

cost3 = driving_cost(400, miles_per_gallon, dollars_per_gallon)

print("%.2f" % cost1)

print("%.2f" % cost2)

print("%.2f" % cost3)

Explanation:

You might be interested in
Which of the following is not a web browser? A. safari B. explorer C. chrome D. google​
Brums [2.3K]

Answer:

D) Google

Explanation:

Google on it's own is a search engine. Safari, Explorer, and Chrome are web browsers.

I hope it helps :)))

7 0
3 years ago
Read 2 more answers
A database stores a large amount data in vertical ___
myrzilka [38]

Records for the first one and table for the second one

4 0
3 years ago
Canada’s energy plan, named __________, makes three governmental agencies accountable for safeguarding Canada’s environment.
stepan [7]

Answer:

Canada launched the national Generation Energy Council of leading Canadians, who proposed principles to the Government of Canada on how to build our energy future. Today, these principles guide government decisions to support Canadian families, businesses, and communities. Together, we are: saving energy powering clean communities.

Explanation:

8 0
2 years ago
All of the following are aspects of the search process except
Len [333]
You need to provide the options or we cant provide you with the incorrect answer.
8 0
3 years ago
I have a lot of stuff on my pc and I want to make my pc brand new from when I bought it, How do I clean my pc to make it where i
stepan [7]
Well if your talking about physically you could get some compressed air and blow it out. Or if your talking about performance you could try to re-install the os you have on it or replace the hdd with a ssd or higher performance hard disk for it to run like new. :)
5 0
3 years ago
Read 2 more answers
Other questions:
  • When you enter search keywords in the search box of file explorer and the onedrive option is selected?
    15·2 answers
  • ________ is digital textual information that can be stored, manipulated, and transmitted by electronic devices.
    7·1 answer
  • ________ is a software that interprets java bytecode.
    12·1 answer
  • What are the two main components on the motherboard?
    12·2 answers
  • Consider the following code: x = 17 y = 5 print (x % y) What is output?
    10·1 answer
  • All of the following are current key technology trends raising ethical issues except:_________
    13·1 answer
  • ____________ is a script or a tool that obtains privileges of a root
    8·1 answer
  • Draw a dfd that shows how data will be stored, processed, and transformed in the tims system
    9·1 answer
  • A student registers for a course in a university. Courses may have limited enrollment i.e a student must
    5·1 answer
  • Choosing a per_formatted presentation that already has a design and the slots is called choosing What​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!