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
A school bus with its flashing red signals on has stopped on a non-divided highway; you must?
g100num [7]

In a case whereby a school bus with its flashing red signals on has stopped on a non-divided highway then  you must stop until the signal lights are no longer flashing and all passengers have cleared the roadway.

<h3>What is the function of red light in traffic rules?</h3>

The function of red light in traffic rules is to tell the other road user that they should stop for a while to tell them thaqt there is a danger.

It should be noted that In a case whereby a school bus with its flashing red signals on has stopped on a non-divided highway then  you must stop until the signal lights are no longer flashing and all passengers have cleared the roadway.

Read more on the traffic here:

brainly.com/question/9380087

#SPJ1

6 0
1 year ago
1. A pipeline constructed of carbon steel failed after 3 years of operation. On examination it was found that the wall thickness
jek_recluse [69]

Answer:

check the explanation

Explanation:

1.

Thickness Loss = t =\frac{t_{o}-t_{i}}{2} = \frac{114.3-102.3}{2} = 2mm

t_{f} = \frac{1}{2}*6 = 3mm

Hence Rate of Corrosion = 6*\frac{1-0.5}{3} = 1mm/year = 0.03 inches per year

2.

As the expected future life is 7 years,

40 carbon steel pipe has to be replaced every 3 years as given in the question,

Cost per unit length is the sum of material cost and installation cost.

Cost of 40 carbon steel = (5 dollars + 16.5 dollars) * 3 = 64.5 dollars

For 80 carbon steel pipe, first calculate the thickness loss,

\frac{114.3-97.2}{2} = 8.55mm

The critical thickness is given to be 3mm, Hence change in thickness is 8.55-3 = 5.5mm

This 80 carbon steel pipe has to be replaced one more time

Hence, Cost per unit length is the sum of material cost and installation cost.

Cost of 80 carbon steel = (8.3 dollars + 16.5 dollars) * 2 = 49.6 dollars

The best is of stainless steel which does not undergo corrosion at all and thus it needs to be replaced only once throughout the plant operation. Its cost = 24.8 dollars + 16.5 dollars = 41.3 dollars

Hence, stainless steel is the recommended pipe to be used.

3 0
3 years ago
When framing a building, a simple way to estimate the total amount of wall studs needed is to allow
Levart [38]
1+1=2
Solution
3:932(2)=61
4 0
3 years ago
Carbon dioxide (CO2) at 1 bar, 300 K enters a compressor operating at steady state and is compressed adiabatically to an exit st
Zielflug [23.3K]

Answer:

A.) 0.08 kJ/kg.K

B.) 207.8 KJ/Kg

C.) 0.808

Explanation:

From the question, the use of fluids mechanic table will be required. In order to get the compressor processes, the kinetic energy and the potential energy will be negligible while applying the ideal gas model.

Since the steam is a closed system, the carbon dioxide will be compressed adiabatically.

Please find the attached files for the solution and the remaining explanation.

6 0
3 years ago
Why do engineers play a variety of roles in the engineering process?
Crazy boy [7]

Answer: The engineering design process emphasizes open-ended problem solving and encourages students to learn from failure. This process nurtures students abilities to create innovative solutions to challenges in any subject! In addition to their involvement in design and development, many engineers work in testing, production, or maintenance. These engineers supervise production in factories, determine the causes of a component's failure, and test manufactured products to maintain quality.

Explanation:

6 0
2 years ago
Other questions:
  • A composite wall consists of 20 mm thick steel plate backed by insulation brick (k = 0.39 W/mK) of 50 cm thickness and overlaid
    6·1 answer
  • In order to test the feasibility of drying a certain foodstuff, drying data were obtained in a tray dryer with air flow over the
    14·1 answer
  • A household refrigerator that has a power input of 450 W and a COP of 1.5 is to cool 5 large watermelons, 10 kg each, to 8 C. If
    7·1 answer
  • Given a series of numbers as input, add them up until the input is 10 and print the total. Do not add the final 10. For example,
    7·1 answer
  • If you play roblox leave user down bellow
    14·2 answers
  • if a voltage is applied to a capacitor, current flows easily at first and then slows as the capacitor becomes charged. Inductors
    5·1 answer
  • How do you connect several springs to increase the equivalent stiffness? What is one example from industry or other real-life si
    7·1 answer
  • People learn best in different ways. By combining all the group presentations, your class will explain how they see the optical
    8·2 answers
  • A___ remote control can be an advantage to an
    14·2 answers
  • You insert a dielectric into an air-filled capacitor. How does this affect the energy stored in the capacitor?.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!