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
butalik [34]
3 years ago
8

Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 5

0 miles, and 400 miles. Ex: If the input is 20.0 3.1599, the output is: 1.57995 7.89975 63.198 Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. First use the dollars/gallon and miles/gallon values to calculate the dollars/mile. Then use the dollars/mile value to determine the cost per 10, 50, and 400 miles. Note: Real per-mile cost would also include maintenance and depreciation.
Computers and Technology
1 answer:
omeli [17]3 years ago
5 0

Answer:

The Following are the code to this question:

def cost(miles, milesPerGallon, dollarsPerGallon):##defining a method cost that accepts three parameter

   return miles / milesPerGallon * dollarsPerGallon# calculate cost and return it value  

milesPerGallon = float(input('Enter miles/Gallon value: '))#defining variable milesPerGallon for user input  

dollarsPerGallon = float(input('Enter dollars/ Gallon value: '))#defining variable dollarsPerGallon for user input

print('{:.5f}'.format(cost(10, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.5f}'.format(cost(50, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.3f}'.format(cost(400, milesPerGallon, dollarsPerGallon)))#call method and print its value

Output:

Enter miles/Gallon value: 20.0

Enter dollars/ Gallon value: 3.1599

1.57995

7.89975

63.198

Explanation:

In the above-given code, a method "cost" is defined, that accepts three value "miles, milesPerGallon, and dollarsPerGallon" in its parameter, and use the return keyword for calculating and return its value.

In the next step, two variable "milesPerGallon, and dollarsPerGallon" is declared, that use the input method with float keyword for input floating-point value.

After input value, it uses a print method with different miles values, which are "10,50, and 400", and input value to pass in cost method to call and print its return value.

You might be interested in
Which of the following is not a use of a hash function
soldi70 [24.7K]

Answer:

the answer would be there

Explanation:

7 0
2 years ago
BRAINLIEST plz help
avanturin [10]

Answer:C

Explanation:

8 0
3 years ago
What is a specific challenge faced by information visualization researchers who are building an interface?
Mkey [24]

Answer:

 Information virtualization is the process of representing the abstract data such as numeral number and text into the form of visual which is human can easily understand.

The main challenges faced by the information visualization researchers are:

  • The main challenge which are faced by the information virtualization is during the data importing and also cleaning in the system.
  • It also not able to access the large amount of the data easily from the system.
  • Due to the poor selection of the scale and the coordinate rotation it also lead to the data distortion.
3 0
3 years ago
Select the correct text in the passage.
oksian1 [2.3K]

Answer:

Answer is given below

Explanation:

The index of the smallest value returned by function positionMin(),

and it is done by line "return minPosition;"

The input array is given as an argument in function selSort() and it is done by line "public static void selSort(int [] vals)" Here vals is input array argument.

6 0
3 years ago
Emily has to create an audio-visual presentation on animated movies. Which input device will she be LEAST likely to use while cr
Slav-nsk [51]
A joystick is less likely to be used while creating this presentation. Obviously, If your intention is to create an audio-visual presentation on animated movies, a computer should be used. With a computer, comes a keyboard, a mouse and a microphone as well.

A Joystick is used to control video games and play simulator games. Therefore, I do not see the need of using a joystick in this situation.

6 0
3 years ago
Other questions:
  • To join two or more objects to make a larger whole is to _____________ them.
    8·2 answers
  • Musccanic Inc., a company that manufactures microprocessors, updates the technology used in its microprocessors once every four
    15·1 answer
  • Assume that the following code exists inside a method of SomeClass, and that this code compiles without errors:
    13·1 answer
  • What is the best information to include in the template name to differentiate it from other templates? Check all that apply.
    6·1 answer
  • Which one of the following will not be considered as a microcomputer?
    12·2 answers
  • Which type of CPU instruction performs arithmetic calculations and stores the results in memory?
    14·2 answers
  • What does mean I can’t turn on my computer and my computer won’t charge at all
    15·1 answer
  • Help me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!​
    9·1 answer
  • Python will ignore any line of code that begins with hashtag true or false​
    13·2 answers
  • Viruses and Malware Complete the case project on page 82 of the textbook by researching two types of viruses, two types of malwa
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!