-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab_02.java
More file actions
66 lines (48 loc) · 2.04 KB
/
lab_02.java
File metadata and controls
66 lines (48 loc) · 2.04 KB
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
import java.util.Scanner;
public class lab_02 {
public static void main(String[] args) {
String car;
double distance;
double fuel_Consumed ;
double pricePerLiter;
double cost;
double perLFC;
System.out.println("Enter the car name");
Scanner c=new Scanner(System.in);
car=c.nextLine();
System.out.println("Distance travelled by the car in Km");
Scanner d=new Scanner(System.in);
distance=d.nextDouble();
System.out.println("Price per liter in rupees");
Scanner ppl=new Scanner(System.in);
pricePerLiter=ppl.nextDouble();
System.out.println("Total fuel consumed in liters");
Scanner obj=new Scanner(System.in);
fuel_Consumed=obj.nextDouble();
perLFC=(distance/fuel_Consumed);
cost=fuel_Consumed*pricePerLiter;
System.out.println("CAR : "+car);
System.out.println("distace travelled : "+distance);
System.out.println("Fuel price per liter is : "+pricePerLiter);
System.out.println("Total fuel consumed in liters : "+fuel_Consumed);
System.out.println("Per Km fuel consumption : "+perLFC);
System.out.println("The total cost in rupees is : "+cost);
if(perLFC>=20){
System.out.println("Your car is highly fuel efficient");
}
else
if(perLFC>=15 && perLFC<20){
System.out.println("Your car is fuel efficient");
}
else
if(perLFC<=15 && perLFC>10){
System.out.println("Your need to show your car to a mechanics");
}
else
if(perLFC<10){
System.out.println("Your car need tuning");
}
else
System.out.println("invalid input");
}
}