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
If the old radiator is replaced with a new one that has longer tubes made of the same material and same thickness as those in th
Nookie1986 [14]

Answer: hello some parts of your question is missing attached below is the missing information

The radiator of a car is a type of heat exchanger. Hot fluid coming from the car engine, called the coolant, flows through aluminum radiator tubes of thickness d that release heat to the outside air by conduction. The average temperature gradient between the coolant and the outside air is about 130 K/mm . The term ΔT/d  is called the temperature gradient which is the temperature difference ΔT between coolant inside and the air outside per unit thickness of tube

answer : Total surface area = 3/2 * area of old radiator

Explanation:

we will use this relation

K = \frac{Qd }{A* change in T }

change in T =  ΔT  

therefore New Area  ( A ) = 3/2 * area of old radiator

Given that the thermal conductivity is the same in the new and old radiators

3 0
3 years ago
The three resistors in the circuit shown have values of 4ohms 4ohms and 2ohms. The battery has a value of 12 volts. What is the
gtnhenbr [62]

Answer:

2ohms

Explanation:

3 0
3 years ago
Water at 200C flows through a pipe of 10 mm diameter pipe at 1 m/s. Is the flow Turbulent ? a. Yes b. No
Degger [83]

Answer:

Yes, the flow is turbulent.

Explanation:

Reynolds number gives the nature of flow. If he Reynolds number is less than 2000 then the flow is laminar else turbulent.

Given:

Diameter of pipe is 10mm.

Velocity of the pipe is 1m/s.

Temperature of water is 200°C.

The kinematic viscosity at temperature 200°C is 1.557\times10^{-7}m2/s.

Calculation:

Step1

Expression for Reynolds number is given as follows:

Re=\frac{vd}{\nu}

Here, v is velocity, \nu is kinematic viscosity, d is diameter and Re is Reynolds number.

Substitute the values in the above equation as follows:

Re=\frac{vd}{\nu}

Re=\frac{1\times(10mm)(\frac{1m}{1000mm})}{1.557\times10^{-7}}

Re=64226.07579

Thus, the Reynolds number is 64226.07579. This is greater than 2000.

Hence, the given flow is turbulent flow.

5 0
3 years ago
__________<br> is an accurate way of drawing that shows an object's<br> true size and shape.
Bingel [31]
ANSWER:

Detail drawing
6 0
3 years ago
In order to defend against side channel power analysis, we should: ______________
wariber [46]

Answer:

Some examples of predator and prey are lion and zebra, bear and fish, and fox and rabbit. ... The words "predator" and "prey" are almost always used to mean only animals that eat animals, but the same concept also applies to plants: Bear and berry, rabbit and lettuce, grasshopper and leaf

Explanation:

8 0
3 years ago
Other questions:
  • A square loop of wire surrounds a solenoid. The side of the square is 0.1 m, while the radius of the solenoid is 0.025 m. The sq
    6·1 answer
  • In the 5 Code of Federal Regulations (C.F.R.), it is recommended that an individual has security awareness training before s/he
    8·2 answers
  • You will be observing laminar-turbulent transition for room temperature (about 20°C) water flowing in a 0.602"" ID pipe (Schedul
    8·1 answer
  • Cool water at 15°C is throttled from 5(atm) to 1(atm), as in a kitchen faucet. What is the temperature change of the water? What
    7·1 answer
  • 1) What output force (Fout) is produced if the lever arm length (rout) is 100 mm?
    13·2 answers
  • Which of the following machine parts always require
    12·1 answer
  • What is the process pf distributing and selling clean fuel?​
    6·1 answer
  • A red circle and diagonal slash on a sign means that:.
    10·1 answer
  • A traffic flow has density 61 veh/km when the speed is 59 veh/hr. If a flow has a jam density of 122 veh/km, what is the maximum
    13·1 answer
  • Assume the availability of an existing class, ICalculator, that models an integer arithmetic calculator and contains: an instanc
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!