Hi all! My assignment question is this:
Write a program that asks the user to input
• The number of gallons of gas in the tank
• The fuel efficiency in miles per gallon
• The price of gas per gallon
Then print the cost per 100 miles and how far the car can go with the gas in the tank.
Thus far, I've written the code:
public class assignmenti
{
public static void main ( String args[] )
{
Scanner keyboard = new Scanner(System.in);
double gallons, milesPerGallon, pricePerGallon;
//Get input
System.out.println("Gallons in the tank?");
gallons = keyboard.nextdouble();
System.out.println("Fuel efficiency?");
milesPerGallon = keyboard.nextdouble();
System.out.println("Price of gas per gallon?");
pricePerGallon = keyboard.nextdouble();
// Print output
System.out.println("Cost per 100 miles:" + ((100/milesPerGallon) * pricePerGallon) + "Dollars");
System.out.println("How far the car can go:" + (gallons * milesPerGallon) + "miles");
}
}
But it won't compile inside my terminal. Anyone see any detrimental errors here as to why my program isn't working?