Hello everyone. I am new to java and am stuck on a problem i need to complete. The problem asks for me to create a program that calculates daily driving cost. The application needs to have total miles driven, cost per gallon, mpg, parking fees and tolls. Now, my professor doesnt like to teach us anything but still expects us to know everyting so i have been struggling a little bit. i have determined i need to use "double" instead of "int"....but when i go to do the math for this it gives me syntax error. How would i go about doing math using the double instead of int? here is what i have so far. would really appreciate it if sombody could help me out. The data that needs to be used is in my code. I also need to print the results using printf, which im a little lost on.
import java.util.Scanner;
public class carpoolsavings {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
int total;
int distance = 200;
double ppg = 2.79;
double parking = 5.50;
double tolls = .35;
double mpg = 31.5;
total = (distance / mpg * ppg + parking + tolls);
System.out.printf("Total Price is " + total );
}
}