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
alexgriva [62]
3 years ago
9

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);
Computers and Technology
2 answers:
pickupchik [31]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:

Allisa [31]3 years ago
6 0

Answer:

The C program is given below.

#include<stdio.h>

int main() {

   double speed, gas_cost, cost_1, cost_10, cost_50, cost_400;    

   printf("Enter car's speed in miles/gallon  ");

   scanf("%lf", &speed);    

   printf("Enter cost of gas in dollars/gallon  ");

   scanf("%lf", &gas_cost);    

   // fraction gives the gallons of gas needed for 1 mile.

   // gallons of gas needed for 1 mile * cost of 1 gallon of gas = gas cost for 1 mile

   cost_1 = (1/speed)*gas_cost ;    

   // cost of gas for 10 miles

   cost_10 = cost_1 * 10;

   printf("Cost of gas for 10 miles in dollars is  ");

   printf( "%0.2f", cost_10 );

   printf("\n");    

   // cost of gas for 50 miles

   cost_50 = cost_1 * 50;

   printf("Cost of gas for 50 in dollars miles is  ");

   printf( "%0.2f", cost_50 );

   printf("\n");    

   // cost of gas for 400 miles

   cost_400 = cost_1 * 400;

   printf("Cost of gas for 400 in dollars miles is  ");

   printf( "%0.2f", cost_400 );

   printf("\n");    

   return 0;

}

OUTPUT

Enter car's speed in miles/gallon  20                                                                                          

Enter cost of gas in dollars/gallon  30                                                                                        

Cost of gas for 10 miles in dollars is  15.00                                                                                  

Cost of gas for 50 in dollars miles is  75.00                                                                                  

Cost of gas for 400 in dollars miles is  600.00  

Explanation:

This program takes user input for cost of gas in dollars and speed of the car in miles per gallon.

Next, gallons needed for 1 mile is calculated.  

cost_1 = (1/speed)*gas_cost ;

Following this, gallons needed for 10 miles, 50 miles and 400 miles are calculated.

cost_10 = cost_1 * 10;

cost_50 = cost_1 * 50;

cost_400 = cost_1 * 400;

These values are displayed on the screen with two decimal places by using printf( "%0.2f", your_value).

All the variables needed in this program are declared as double.

All the instructions mentioned have been implemented. This program can be tested for all possible positive numbers.

You might be interested in
IN YOUR OWN WORDS, create a new thread and compare and contrast paraphrasing, summarizing, and quoting and how to do each succes
choli [55]

Answer:

Such three ways to include the work of other writers in your own writing differ depending on whether you are close to the source.

Explanation:

Quotations must be the same as the original, using a narrow source segment. We must be word for word on the source document and the original author must be credited.

Paraphrasing means putting your own words into a line from the source material. The original source should also be assigned a paraphrase. Paraphrased material usually is shorter than the original one, which takes and slightly condenses a somewhat broader part of the source.

In summary, you have to put the main idea(s), including only the main point(s), in your own words. Again, summarized ideas must be attributed to the source. Summaries are much shorter than the original and give a broad overview of the source documents.

8 0
4 years ago
Which phrases suggest that Bob is a web administrator?
aliina [53]

"creates a weekly backup from a remote web server"

This implies that he is the owner of the server since, one, he backs it up every week, and two, he has access to create a backup.

3 0
3 years ago
What information should be included in the closing paragraph of a thank-you letter? a. Mention skills that were omitted during t
stiks02 [169]
The answer is c and sorry for being so rude I didn't realize it was you girly

3 0
3 years ago
Read 2 more answers
What is the definition of Microsoft Operating System?<br>​
MaRussiya [10]

Answer:

Operating system designed and produced by Microsoft Corporation. Similar to other operating systems, Windows makes a computer system user-friendly by providing a graphical display and organizing information so that it can be easily accessed.

Explanation:

6 0
3 years ago
Read 2 more answers
Which of the following is not one of the current changes taking place in information systems​ technology? A. Growth in cloud com
lana66690 [7]

Answer:

Growth in the PC platform

Explanation:

Information system technology refers to study, design, implementation, management, support - of computer based information system.

In today's technical growth age : the area has undergone many dynamic changes :

Changes of technical upgradation & application of IT info - Growth in cloud computing,  Increased usage of data generated by the Internet of Things, Emerging mobile digital platform, Growing business use of big data

However, Growth of PC platform is not one of the current changes taking place in information systems​ technology.

6 0
3 years ago
Other questions:
  • Which of the following is not an algorithm?
    8·1 answer
  • What is an advantage of taking notes in a digital format?
    6·2 answers
  • Modify the Eggs program to create a new one named EggsInteractive that prompts the user for and accepts a number of eggs for eac
    13·1 answer
  • Create a GUI application that allows the user to select a rate category (from a set of radio buttons), and enter the number of m
    6·1 answer
  • How to build a 5*32 decoder by using 3*8 and 2*4 decoders? (digital design)
    7·1 answer
  • Function countValues = CreateArray(endValue) % endValue: Ending value of countValues
    7·1 answer
  • of the menu items listed at the top of the screen, which will be used to determine what the shortcut f6 means in primesuite?
    5·1 answer
  • A pre-design document you can use to create a new project quickly
    5·1 answer
  • Star and peer-to-peer are types of
    9·2 answers
  • Can we update App Store in any apple device. (because my device is kinda old and if want to download the recent apps it aint sho
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!