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
Calculate the time complexity for the following function in terms of Big O notation. Explain your answer.
DerKrebs [107]

Answer: It is 1 int count = 0;

2 for (int i = n; i >= 0; i /= 2)

3 count += i;

4 for (int j = 0; j < n; j++)

5 count +=j;

6 return count;

SO it is j(0-(-n)

Explanation: Im dum

4 0
2 years ago
A ___describes a particular attribute of the dates item in a table​
Vikentia [17]

Answer:

\huge\star{\underline{\mathtt{\red{A}\red{n}\red{s}\red{w}\red{e}\red{r}}}}\huge\star

.

<h3><em>A</em><em><u> objective</u></em><em><u> </u></em><em><u>of</u></em><em><u> technique</u></em><em> </em><em>describes a particular attribute of the dates item in a table</em><em>.</em></h3>

<em>.</em>

<em>I </em><em>hope</em><em> </em><em>this</em><em> </em><em>helps</em><em> </em><em>you</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em>

5 0
3 years ago
Reading for subject content follows the same steps as reading for entertainment. True or false.
marshall27 [118]

The answer is false.  There is a difference between reading for entertainment or leisure and reading for subject content.  In the latter, you have to scan what you are reading carefully.  There are keywords and sentences that you have to watch out for to get the whole idea of the document that you are reading.

5 0
3 years ago
Read 2 more answers
Given three packets of size 2,500 Bytes (caution this is Bytes not bits) each are ready inside computer 1 to be transmitted onto
gizmo_the_mogwai [7]

Answer: umm sorry

Explanation:

5 0
3 years ago
Write a program in java to enter a character.The program displays the message "uppercase vowel" if entered character is uppercas
horrorfan [7]

Answer:

d

Explanation:

i think

3 0
3 years ago
Other questions:
  • Instructions:Drag the tiles to the boxes to form correct pairs.
    11·2 answers
  • Jennifer frequently uses a few programs on her laptop. Where will she find all the frequently used program icons in her computer
    13·1 answer
  • Instructions:Select the correct answer from each drop-down menu. What type of font color should Kim select if she chooses a dark
    10·2 answers
  • Which type of NAC agent will be used during the posture assessment before allowing access to the VPN users?
    9·1 answer
  • Ad identifies and describes at least four ways to prevent downloading of spyware, adware, and viruses to computer
    9·1 answer
  • Define a new class Fighter that inherits from Spaceship. Add a variable property weapon that defaults to an empty string and a v
    14·1 answer
  • _____the measuring instrument is not necssery​
    10·1 answer
  • You wrote a program to allow to guess a number chosen randomly.
    10·2 answers
  • How do you create multiple columns in Word?
    12·1 answer
  • ASAP BRAINLIEST!!!!!!
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!