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

Program Specifications Your program will prompt the user for a floating point nu

ID: 3542023 • Letter: P

Question

Program Specifications

Your program will prompt the user for a floating point number which stands for gallons of gasoline. You will reprint that value along with other information about gasoline and gasoline usage:

You can find these measures on the web (try wikipedia), but just in case:

Please enter the number of gallons of gasoline:100 Original number of gallons is: 100.0 00.0 gallons is the equivalent of 378.54 liters 100.0 gallons of gasoline requires 5.12820512821 barrels of oil 100.0 gallons of gasoline produces 2000.0 pounds of C02 100.0 gallons of gasoline is energy equivalent to 151.915455746 gallons of ethanol 100.0 gallons of gasoline requires 400.0 US dollars Thanks for playing

Explanation / Answer

import java.util.*;
public class gasoline
{
    public static void main(String[] args)
    {
double volume;
Scanner in = new Scanner(System.in);
System.out.println("Please Enter the number of gallons of gasoline :");
volume = in.nextDouble();
System.out.println("Original number of gallons is :" + volume);
System.out.println(volume + " gallons is equivalent of " + (volume*3.7854) + " liters");
System.out.println(volume + " gallons of gasoline requires " + (volume/19.5 ) + " barrels of oil");
System.out.println(volume + " gallons of gasoline produces   " + (volume*20) + " pounds of CO2");
System.out.println(volume + " gallons of gasoline is energy equivalent to   " + (volume*115000/75700) + " gallons of ethanol");
System.out.println(volume + " gallons of gasoline requires " + (volume*4 ) + " U S dollars");
System.out.println("Thanks for playing");
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote