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
75,15,25,5,15 what's next
Fittoniya [83]

Answer:

3

Explanation:

The sequence seems to follow a 2-step pattern.

1)Divide the first number by 5 to get the second number.

2)Add 10 to the second number to get the third number.

75/5 = 15

15 + 10 = 25

25/5 = 5

5 + 10 = 15

---> 15/5 = [3] (Answer)

3 0
3 years ago
Which of the following statements is TRUE? C++ functions can return a value of type array if it is returned as a base address va
lesantik [10]

Answer:

The answer to this question is "C++ functions can't return array type value".

Explanation:

In C++ language the method is a collection of declarations executing a process together. It is a statement, that tells the compiler to return and accept parameters of a function. In C++, it includes many standardized functions, which can be called by the software, and other choices were wrong, which can be described as follows:

  • In c++ function can't return array type always.  
  • function is not address based.  
  • If array is local to function, but function will not return array value.
3 0
3 years ago
What is the advantage of breaking your application’s code into several small procedures?
Sholpan [36]

Answer: For better code management and modularity

Explanation:

An application consist several lines of code so when we break an entire code into several small procedures it becomes easy to maintain and look for errors while debugging. This process also is part of good code writing and hence easy to manage our code during testing and debugging phases of application development.

3 0
3 years ago
_________ cards contain a chip that can store a large amount of information as well as on a magnetic stripe for backward compati
wariber [46]

Answer:

Smart

Explanation:

The RFID or the radio frequency identification is an electronic device that stores information electronically. It stores and makes available the information which is stored electromagnetically, once the user is authenticated.

This technology is implemented in market places and other individual activities. It is implemented in cards called smart card for ease of payment transaction and promote online commerce (e-commerce). It is also implemented in smartphones.

3 0
3 years ago
When should you try to photograph reflections on bodies of water?
Wewaii [24]

Answer:  C. although a rainy day (A) would make it more aesthetic

6 0
3 years ago
Other questions:
  • A variation of pronounce is a. Proclaim c. Produce b. Profound d. Pronunciation Please select the best answer from the choices p
    11·1 answer
  • In what year was the 1st zelda game released
    5·2 answers
  • 1- Which of the following is the java keyword used to declare a class?
    5·2 answers
  • When describing memory, ____________ is the first component required in the process necessary for retention?
    10·1 answer
  • 3. When you right-click a linked spreadsheet object, what commands do you choose to activate the Excel features?
    7·2 answers
  • If the algorithm does not have instructions for unanticipated results, the computer program will a. solve a problem b. start ove
    6·1 answer
  • Which of these expressions is used to check whether num is equal to value?
    13·1 answer
  • NumA=2<br> for count range (5,8)<br> numA=numA+count <br> print(numA)
    15·1 answer
  • What are some signs that could help you determine that a date and time was inserted as a special object instead of
    14·1 answer
  • 40 points for this question
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!