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
Troyanec [42]
3 years ago
9

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the ga

s 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:
print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3))

Ex: If the input is:

20.0
3.1599
Then the output is:

3.16 11.85 79.00
Computers and Technology
2 answers:
Katen [24]3 years ago
8 0

Answer:

# Program in Python

# Take miles/gallon as input from user

miles_per_gallon = float(input('Please enter cars miles/gallon: '))

# Take dollars/gallon as input from user

dollars_per_gallon = float(input('Please enter gas dollars/gallon: '))

# Formula for calculating gas cost

dollars_per_mile = dollars_per_gallon/miles_per_gallon

# Gas cost for 20 miles

your_value1 = 20 * dollars_per_mile

# Gas cost for 75 miles

your_value2 = 75 * dollars_per_mile

# Gas cost for 500 miles

your_value3 = 500 * dollars_per_mile

# Display the results as output

print('{:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3))

Explanation:

First of all take miles/gallon and dollars/gallon as input from user  and store them in their respective variables. Then calculate the gas cost by dividing dollars/gallon with miles/gallon. Multiply this calculated cost with 20, 75 and 500 respectively. Finally display the results by using print statement.

Output:

Please enter cars miles/gallon: 20.0

Please enter gas dollars/gallon: 3.1599

3.16 11.85 79.00

hram777 [196]3 years ago
8 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
What is the purpose of lookup tables in spreadsheet software
garik1379 [7]

You can easily find and changed the data by using lookup table. You can also find the data within few seconds.

7 0
3 years ago
Read 2 more answers
Which code snippet is the correct way to rewrite this in Semantic HTML?
xxMikexx [17]

Answer:

<div id="header">

<h1>Waketech</h1>

</div>

<header><h1>Waketech</h1></header>

Explanation:

I think thats the answer your welcome

8 0
1 year ago
What are some of the benefits of project
galina1969 [7]

Answer:

The project is more likely to be finished on  time.

Tasks can be done more efficiently.

Explanation:

Project management refers to the process involved in the management and accomplishment of the project. It includes the process, techniques, and guidance to carry on to complete a project. Project management helps in achieving the desired outcomes of the project. The efficient use of the resources and the proper management of the skills are ensured in project management. Better communication and an increase in satisfaction help in improving productivity.

4 0
3 years ago
Which of the following websites can help you learn about general career trends?
Ber [7]
The answer is vocational information center as this area or website provides a person or a student to explore careers that could be suitable to his or her liking and to show careers or professions' role as they work. This website is a way of educating an individual of having to provide informations regarding about careers.
8 0
3 years ago
I'm using assembly language. This is my assignment. I kinda confused about how to write code for this assignment. Can anyone exp
Brut [27]

Answer:

oid changeCase (char char_array[], int array_size ) {

__asm{

   mov eax, char_array;    

   mov edi, 0;

readArray:

   cmp edi, array_size;

   jge exit;

   mov ebx, edi;          

   shl ebx, 2;

   mov cl, [eax + ebx];    

check:

   //working on it

   cmp cl, 0x41;      

   jl next_indx;

   cmp cl, 0x7A;      

   jg next_indx;

   cmp cl, 'a';

   jl convert_down;

   jge convert_up;

convert_down:

   or cl, 0x20;        //make it lowercase

   jmp write;

convert_up:

   and cl, 0x20;      

   jmp write;

write:

   mov byte ptr [eax + ebx], cl    

next_indx:

   inc edi;

exit:

   cmp edi, array_size;

   jl readArray;

mov char_array, eax;

}

}

Explanation:

  • Move char_array to eax as it is base image .
  • Use ebx as offset .
  • Use ecx as the storage register .
  • check if cl is <= than ASCII value 65 (A) .
6 0
3 years ago
Other questions:
  • People with healthy media diets:
    12·1 answer
  • Consider the class Money declared below. Write the member functions declared below and the definition of the overloaded +. Modif
    13·1 answer
  • How can you add contrast between text and headlines in a document? increase the font size of the headline make the headline long
    6·1 answer
  • Which would be a responsible use of technology used by victims of cyberbullying?
    12·2 answers
  • Graphic software task​
    7·1 answer
  • Please answer the following essay question:
    13·1 answer
  • When adjusting the aperture, an F-stop of F32 lets in more light then a setting of F8
    10·1 answer
  • Create a Python program that computes the cost of carpeting a room. Your program should prompt the user for the width and length
    10·1 answer
  • Barbara, an employee, has properly connected her personal wireless router to a network jack inside her office. The router is una
    7·1 answer
  • Each of the flowchart segments in Figure 3-24 is unstructured. Redraw each segment so that it does the same processes under the
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!