I really need help with this JAVA lab. I'm not calling the methods correctly and cant figure out how to correctly calculate the total cost of gas in my last method. In the attached image is the instructions and what my output should look like. I have to use at least 4 helper methods. At the bottom is my existing code. Thank you
I really need help with this JAVA lab. I'm not calling the methods correctly and cant figure out how to correctly calculate the total cost of gas in my last method. In the attached image is the instructions and what my output should look like. I have to use at least 4 helper methods. At the bottom is my existing code. Thank you
MY CODE:
import java.util.Scanner;
public class esudde00Lab1 {
private static final int CLASS_MEETINGS = 46;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner kb = new Scanner(System.in);
String name = "Meagan Smith";
double MILES_FROM_CAMPUS = 8.5;
int MINUTES_FROM_CAMPUS = 12;
int CAR_MPG = 22;
//user input
System.out.println("What is the cost of gas per gallon?");
double gasPerGallon = kb.nextDouble();
System.out.println("Student mileage report \t\t\t Meagan Smith");
System.out.println("=======================================================");
System.out.println("Miles per trip /t/t/t/t" + MILES_FROM_CAMPUS*2 );
System.out.println("Miles this semester \t\t\t", getMiles(miles));
System.out.println("Cost of gas per gallon \t\t $" + gasPerGallon);
System.out.println("Miles per gallon \t\t\t\t" + CAR_MPG);
System.out.println("Cost of gas per trip \t\t\t $" + (gasPerGallon/CAR_MPG)*(MILES_FROM_CAMPUS*2));
System.out.println("Number of trips \t\t\t\t" + CLASS_MEETINGS);
System.out.println("Hours/min in the car/t/t",getHours(hours)+" hrs",getMinutes(minutes)+"min");
}// end of main method
public static int getHours(int MIN_FROM_CAMPUS )
{
int hours = (MIN_FROM_CAMPUS * 2 * CLASS_MEETINGS)/60;
return hours;
}//end of getHours
public static int getMinutes (int MIN_FROM_CAMPUS)
{
int minutes = (MIN_FROM_CAMPUS * 2 * CLASS_MEETINGS);
return minutes;
}// end of getMinutes
public static int getMiles(int MILES_FROM_CAMPUS)
{
int miles = MILES_FROM_CAMPUS * 2 * CLASS_MEETINGS;
return miles;
}//end of get miles
public static double getGasTotal(double gasPerGallon)
{
int CAR_MPG = 22;
double gasTotal =
}
}//end of program
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images