answer.
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
Tems11 [23]
1 year ago
12

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 10 miles, 50 miles, and 400 miles.Output each floating-point value with two digits after the decimal point, which can be achieved as follows:printf("%0.2of", your Value);X: If the input is:20.0 3.1599the output is:1.58 7.90 63.20Note: Real per-mile cost would also include maintenance and depreciation.
Computers and Technology
2 answers:
Yuki888 [10]1 year ago
8 0

Answer:

#program in Python.

#function to calculate driving cost

def driving_cost(d_miles, m_per_gallon, doll_per_gallon):

  #calculate cost and return the value

  return (d_miles / m_per_gallon) * doll_per_gallon

#read the miles per gallon  

m_per_gallon = float(input("Enter car's miles/gallon:"))

#read dollars per gallon

doll_per_gallon = float(input("Enter gas dollars/gallon:"))

#call function to find cost for 10 miles

print('%0.2f' % driving_cost(10, m_per_gallon, doll_per_gallon))

#call function to find cost for 50 miles

print('%0.2f' % driving_cost(50, m_per_gallon, doll_per_gallon))

#call function to find cost for 400 miles

print('%0.2f' % driving_cost(400, m_per_gallon, doll_per_gallon))

Explanation:

Read the value of miles per gallon and assign it to variable "m_per_gallon". Then read dollars per gallon from user and assign it to variable "doll_per_gallon". Call the function driving_cost() with parameter miles, m_per_gallon and doll_per_gallon. This function will find the cost of driving and return the cost.Call function for  10, 50 and 400 miles.

Output:

Enter car's miles/gallon:20                                                            

Enter gas dollars/gallon:3.1599                                                  

1.58                                                                              

7.90                                                                                                    

63.20

I am Lyosha [343]1 year ago
5 0

Answer:

#program in Python.

#function to calculate driving cost

def driving_cost(d_miles, m_per_gallon, doll_per_gallon):

   #calculate cost and return the value

   return (d_miles / m_per_gallon) * doll_per_gallon

#read the miles per gallon  

m_per_gallon = float(input("Enter car's miles/gallon:"))

#read dollars per gallon

doll_per_gallon = float(input("Enter gas dollars/gallon:"))

#call function to find cost for 10 miles

print('%0.2f' % driving_cost(10, m_per_gallon, doll_per_gallon))

#call function to find cost for 50 miles

print('%0.2f' % driving_cost(50, m_per_gallon, doll_per_gallon))

#call function to find cost for 400 miles

print('%0.2f' % driving_cost(400, m_per_gallon, doll_per_gallon))

Explanation:

Read the value of miles per gallon and assign it to variable "m_per_gallon". Then read dollars per gallon from user and assign it to variable "doll_per_gallon". Call the function driving_cost() with parameter miles, m_per_gallon and doll_per_gallon. This function will find the cost of driving and return the cost.Call function for  10, 50 and 400 miles.

Output:

Enter car's miles/gallon:20                                                                                                

Enter gas dollars/gallon:3.1599                                                                                            

1.58                                                                                                                      

7.90                                                                                                                      

63.20

You might be interested in
Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
kolbaska11 [484]

Answer: Decoupling action of the process address space refers to the physical memory of the device getting decoupled to provide  address translation in automatic way. The benefit of this method is as follows:-

  • Faster starting up of the program
  • The physical address space gets managed on its own
  • Helps in execution of large program when the main memory of the machine is of  smaller size in comparison with program

7 0
2 years ago
In a system where Round Robin is used for CPU scheduling, the following is TRUE when a process cannot finish its computation dur
masha68 [24]

Answer:

B. The process will be terminated by the operating system.

Explanation:

When Round Robin is used for CPU scheduling, a time scheduler which is a component of the operating system is used in regulating the operation. A time limit is set for each of the processes to be run.

So, when a process fails to complete running before its time elapses, the time scheduler would log it off and return it to the queue. This queue is in a circular form and gives each of the processes a chance to run its course.

7 0
1 year ago
Ishaan is confused between the terms webpage and website help him in understanding the difference between both​
alexgriva [62]

Answer:

A webpage is a class website and a website is a link where you can find useful information.

Explanation:

Please follow

7 0
2 years ago
Peter took a selfie in his room. He was a wearing a light blue shirt. But he failed to realize that that shirt would clash in co
Leto [7]

Answer:

A wand tool is to do that in an editing software.

7 0
2 years ago
Read 2 more answers
Each of these is a basic type of a touch screen, except ________.
Oksanka [162]
<span>A touch screen gives response and acts simply with a touch on the screen area. Reflective screen is not a basic type of touch screen. The reflection can be reduced for the touch screen when it is combined with the LCD and the screen still be very visible. These screens can be anti glare and safe to the eyes.</span>
8 0
2 years ago
Read 2 more answers
Other questions:
  • Gloria needs to show in spreadsheet form the number of students in her class who speak different languages. Which type of graph
    7·1 answer
  • The tuna marketers' task in the "tunathewonderfish.com" website and related campaign was to ________.
    15·1 answer
  • An mp3 takes up about 16 kilobytes of memory per second of music. if you owned a one terabyte hard drive and filled it with only
    15·1 answer
  • Edward has started up a new company with his friend, Matthew. Currently, he has only two people working with him. Which type of
    8·1 answer
  • In a system containing CPU 1 and Disk Drive A, the system is instructed to access Track 1, Track 9, Track 1, and then Track 9 of
    12·1 answer
  • When trying to improve performance of a slow system, you notice in Task Manager that the superfetch service is using a high perc
    11·1 answer
  • Which option in the Caption dialog box configures whether the caption appears above or below the image
    11·2 answers
  • Write a method called printRangeOfNumbers that accepts a minimum, maximum numbers as parameters and prints each number from mini
    6·1 answer
  • Import simplegui
    10·1 answer
  • Where can the Field Service Manual containing Critical Callout, Disassembly and Reassembly instructions be found?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!