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
Burka [1]
3 years ago
7

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 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: System.out.printf("%.2f", yourValue); The output ends with a newline.
Computers and Technology
2 answers:
Tatiana [17]3 years ago
4 0

Answer:

const double gasDollarPerGallon = 20 ;

float calCost( double milesPerGallon ) {

   double costPerGallon = milesPerGallon / gasDollarPerGallon;

   System.out.printf ("%.2f/n", &costPerGallon);

int main ( ) {

   scanf ("%2f", &gasDollarPerGallon) ;

   calCost( 20 );

   calCost( 75 );

   calCost( 500 );

Explanation:

The C source code above gets the user input of the gas dollar per gallon from the command prompt and divides the miles per gallon variable in the function call to get the cost of gas for the range of miles. It is also print out as a double with two places.

kiruha [24]3 years ago
4 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 diffrence between the the grassland and the savanna biomes
sergey [27]

Answer:

The term "savanna" is often used to refer to open grassland with some tree cover, while "grassland" refers to a grassy ecosystem with little or no tree cover.

Explanation:

5 0
3 years ago
Read 2 more answers
Within a single program, __________________ allows multiple parts, or threads, to run simultaneously.
jekas [21]
<span>It should be single-user/multitasking os.</span>
4 0
3 years ago
Which of the following is a windows that allows you to temporarily store text
musickatia [10]
There are no answer choices listed so I don't have anything to choose from so i'm just going to go with what I know/think. Just from reading the question I think it may be the "notepad." If it is not the notepad then it may be the clipboard.

Sorry if this doesn't help you very much, but there were no answer choices. 
7 0
2 years ago
array Write a recursive function stringReverse that takes a string and a starting subscript as arguments, prints the string back
amm1812

user_in = str ( input ("Please enter a phrase: " ))

def reverse_str (string):

e = 0

for e in range (len (string)):

x = -1

print string[x]

x += (len (string))

8 0
3 years ago
What is the small picture or icon on the screen whose position is controlled by the mouse?
Fittoniya [83]

Answer:

cursor

Explanation:

beacause it uz controlled by pointing device, such as a mouse, pen, or trackball

7 0
2 years ago
Other questions:
  • A slightly tapered thread is characteristic of a _______ tap.
    15·1 answer
  • In report design view, you can use commands on the align button of the _____ tab.​
    11·1 answer
  • What kind of video are you are able to watch by downloading it from the Internet?
    10·1 answer
  • Operational feasibility, which refers to user acceptance and support, as well as management acceptance and support, is also know
    9·1 answer
  • What is the maximum current that should be allowed in a 5.0w 220 resistor?
    12·1 answer
  • A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
    5·1 answer
  • What are three ways a person may use a computer without realizing it?
    9·1 answer
  • Which of the following tells the computer hardware what to do? A Information B) Software Procedures D People
    12·2 answers
  • 236. A system such as a printer, smart TV, or HVAC controller, typically uses an operating system on what is called a:
    13·2 answers
  • In your own opinion how comes the surface grinding machine is called a highly accurate machine tool?​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!