-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrivingcost.java
More file actions
28 lines (18 loc) · 828 Bytes
/
drivingcost.java
File metadata and controls
28 lines (18 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.Scanner;
public class drivingcost {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double miles, costPerGallon, parkingFees, tolls, totalCost;
System.out.print("Enter total miles driven per day: ");
miles = input.nextDouble();
System.out.print("Enter cost per gallon of gasoline: ");
costPerGallon = input.nextDouble();
System.out.print("Enter average parking fees per day: ");
parkingFees = input.nextDouble();
System.out.print("Enter tolls per day: ");
tolls = input.nextDouble();
totalCost = (miles * costPerGallon) + parkingFees + tolls;
System.out.println("\nYour daily driving cost is: " + totalCost);
input.close();
}
}