-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q_7.java
80 lines (67 loc) · 2.51 KB
/
Q_7.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Muhammad Naveed
// (Car-Pool Savings Calculator) Research several car-pooling websites. Create an application that
// calculates your daily driving cost, so that you can estimate how much money could be
// saved by carpooling, which also has other advantages such as reducing carbon emissions and
// reducing traffic congestion. The application should input the following information and display
// the user’s cost per day of driving to work:
// a) Total miles driven per day.
// b) Cost per gallon of gasoline.
// c) Average miles per gallon.
// d) Parking fees per day.
// e) Tolls per day.
import java.util.Scanner;
public class Q_7
{
// public static void main (String [] args) {
//
// // Scanner class object
// Scanner sc = new Scanner (System.in);
//
// int totalMiles;
// int gasolineCost;
// int milesPerGallon;
// int parkingFees;
// int tolls;
// int dailyDrivingCost;
//
// System.out.print ("Enter Total Miles Driven Per Day: ");
// totalMiles = sc.nextInt();
//
// System.out.print ("Enter Cost Per Gallon Of Gasoline: ");
// gasolineCost = sc.nextInt();
//
// System.out.print ("Enter Average Miles Per Gallon: ");
// milesPerGallon = sc.nextInt();
//
// System.out.print ("Enter Parking Fees Per Day: ");
// parkingFees = sc.nextInt();
//
// System.out.print ("Enter Tolls Per Day: ");
// tolls = sc.nextInt();
//
// // closing scanner.
// sc.close();
//
// // calculating daily Driving cost.
// dailyDrivingCost = (totalMiles / milesPerGallon) * gasolineCost + parkingFees + tolls;
//
// System.out.printf ("\nYour Daily Driving Cost Is: %d\n", dailyDrivingCost);
// }
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter total miles per day : ");
int total_Miles = sc.nextInt();
System.out.print ("Enter Cost Per Gallon Of Gasoline: ");
int gasolineCost = sc.nextInt();
System.out.print ("Enter Average Miles Per Gallon: ");
int milesPerGallon = sc.nextInt();
System.out.print ("Enter Parking Fees Per Day: ");
int parkingFees = sc.nextInt();
System.out.print ("Enter Tolls Per Day: ");
int tolls = sc.nextInt();
sc.close();
int dailyDrivingCoast = (total_Miles / milesPerGallon) * gasolineCost + parkingFees + tolls;
System.out.print("Dail Driving Coast => " + dailyDrivingCoast);
}
}