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
FinnZ [79.3K]
3 years ago
7

(Gas Mileage) Drivers are concerned with the mileage their automobiles get. One driver has kept track of several trips by record

ing the miles driven and gallons used for each tankful. Develop a Java application that will input the miles driven and gallons used (both as integers) for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all trips up to this point. All averaging calculations should produce floating-point results. Use class Scanner and sentinel-controlled iteration to obtain the data from the user.
Engineering
1 answer:
Effectus [21]3 years ago
6 0

Answer:

import java.util.*;

public class Main {

   

   public static void main(String[] args) {

     

       double milesPerGallon = 0;

       int totalMiles = 0;

       int totalGallons = 0;

       double totalMPG = 0;

       

       Scanner input = new Scanner(System.in);

 

       while(true){

           System.out.print("Enter the miles driven: ");

           int miles = input.nextInt();

           if(miles <= 0)

               break;

           else{

               System.out.print("Enter the gallons used: ");

               int gallons = input.nextInt();

               totalMiles += miles;

               totalGallons += gallons;

               milesPerGallon = (double) miles/gallons;

               totalMPG = (double) totalMiles / totalGallons;

               System.out.printf("Miles per gallon for this trip is: %.1f\n", milesPerGallon);

               System.out.printf("Total miles per gallon is: %.1f\n", totalMPG);

           }

       }

   }  

}

Explanation:

Initialize the variables

Create a while loop that iterates until the specified condition is met inside the loop

Inside the loop, ask the user to enter the miles. If the miles is less than or equal to 0, stop the loop. Otherwise, for each trip do the following: Ask the user to enter the gallons. Add the miles and gallons to totalMiles and totalGallons respectively. Calculate the milesPerGallon (divide miles by gallons). Calculate the totalMPG (divide totalMiles by totalGallons). Print the miles per gallon and total miles per gallon.

You might be interested in
provides steady-state operating data for a solar power plant that operates on a Rankine cycle with Refrigerant 134a as its worki
Vaselesa [24]

Answer:

hello some parts of your question is missing attached below is the missing part ( the required fig and table )

answer : The solar collector surface area = 7133 m^2

Explanation:

Given data :

Rate of energy input to the collectors from solar radiation = 0.3 kW/m^2

percentage of solar power absorbed by refrigerant = 60%

Determine the solar collector surface area

The solar collector surface area = 7133 m^2

attached below is a detailed solution of the problem

8 0
3 years ago
Which view of an architectural design displays the complex interior features of an object concealed by hidden lines
Klio2033 [76]

Answer:

Cutting-plane View

Explanation:

5 0
3 years ago
How to calculate tension.
Evgen [1.6K]

Answer:

Tension can be easily explained in the case of bodies hung from chain, cable, string

Explanation

uniform speed, tension; T = W.

T=m(g±a)

3 0
2 years ago
The proposed grading at a project site will consist of 25,100 m3 of cut and 23,300 m3 of fill and will be a balanced earthwork j
Anna [14]

Answer:

the volume of water that will be required to bring these soils to the optimum moisture content is 1859 kL

Explanation:

Given that;

volume of cut = 25,100 m³

Volume of dry soil fill = 23,300 m³

Weight of the soil will be;

⇒ 93% × 18.3 kN/m³ × 23,300 m³

= 0.93 × 426390 kN 3

= 396,542.7 kN  

Optimum moisture content = 12.9 %

Required amount of moisture = (12.9 - 8.3)% = 4.6 %

So,

Weight of water required = 4.6% × 396,542.7 = 18241 kN

Volume of water required = 18241 / 9.81 = 1859 m³

Volume of water required = 1859 kL

Therefore, the volume of water that will be required to bring these soils to the optimum moisture content is 1859 kL

6 0
3 years ago
Why is it important to keep hand tools free of oil and grease?
Bezzdna [24]

Answer:

keeps it from rusting

Explanation:

5 0
3 years ago
Other questions:
  • When replacing a timing belt, many experts and vehicle manufacturers recommend that all of the following should be replaced exce
    13·1 answer
  • The jib crane is supported by a pin at Cand rod AB. The rod can withstand a maximum tension of 40 kN. If the load has a mass of
    11·1 answer
  • What are some advantages of generating electrical energy from tides instead of from fossil fuels
    13·1 answer
  • How to solve circuit theory using mesh analysis<br>​
    11·1 answer
  • Free brainlist because im new and i just want to but you have t friend me first
    13·1 answer
  • You have a motor such that if you give it 12 Volt, it will eventually reach a steady state speed of 200 rad/s. If it starts from
    10·1 answer
  • Respond with TRUE if the symbol of the valve shown belows
    5·1 answer
  • Can someone please help!
    8·1 answer
  • What do you think the top TWO game elements are that directly contribute to player immersion?
    15·1 answer
  • How to plot 0.45 gradation chart for sieve analysis ?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!