Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Al\'s Last Chance Gas station sits on Route 190 on the edge of Death Valley. The

ID: 3638490 • Letter: A

Question

Al's Last Chance Gas station sits on Route 190 on the edge of Death Valley. There is no other gas station for 200 kilometers. You are to write a program to help drivers decide if they need gas. The program asks for:
? The capacity of the gas tank, in liters.
? The indication of the gas gauge in percent (full= 100, three quarters full = 75, and so on).
? The kilometers per liter of the car.
The program then writes out "Get Gas" or "Safe to Proceed" depending on if the car can cross the 200 kilometers with the gas remaining in the tank. Use doubles for all input and all arithmetic

Explanation / Answer

Hi, hope this will help import java.util.Scanner; class Gas { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int tank; //capacity of gas tank int gauge; //percent of gas remaining in tank full=100, three-quarters=75, half=50, one-quarter=25 int mpg; //how many miles per gallon the car gets System.out.println("Enter the tank capacity: "); tank = scan.nextInt(); System.out.println("Enter the gauge reading (in percent: 100/75/50/25): "); gauge = scan.nextInt(); System.out.println("Enter the miles per gallon: "); mpg = scan.nextInt(); int actualFuel = (tank * gauge) / 100; int maxDistance = actualFuel * mpg; currentGallons = gaugeReading * tankCapacity / 100; maximumDistance = currentGallons * milesPerGallon; if ( tankCapacity * milesPerGallon < 200) { System.out.print("Get another car, yours cannot go that far"); } if (maxDistance < 200) { System.out.println("Get gas!"); } else { System.out.println("Good to go!"); } } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote