-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathVehicleLoanAndInsurance.java
More file actions
65 lines (51 loc) · 1.57 KB
/
VehicleLoanAndInsurance.java
File metadata and controls
65 lines (51 loc) · 1.57 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
package PackFATPrep;
import java.util.Scanner;
interface VehicleLoan {
double issueVehicleLoan();
}
interface InsuranceForVehicle {
int getInsurance();
}
public class VehicleLoanAndInsurance implements VehicleLoan, InsuranceForVehicle {
String vehicleNo;
String model_Name;
String vehicle_Type;
double price;
Q2(String vehicleNo, String model_Name, String vehicle_Type, double price) {
this.vehicleNo = vehicleNo;
this.model_Name = model_Name;
this.vehicle_Type = vehicle_Type;
this.price = price;
}
public double issueVehicleLoan() {
if (vehicle_Type.equals("four wheeler")) {
return 0.85 * price;
}
if (vehicle_Type.equals("three wheeler")) {
return 0.7 * price;
}
if (vehicle_Type.equals("two wheeler")) {
return 0.5 * price;
}
return 0;
}
public int getInsurance() {
if (price <= 550000) {
return 6500;
}
if (price <= 900000 ) {
return 8000;
}
if (price > 900000) {
return 10000;
}
return 0;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Q2 user = new Q2("1111", "Homda", "four wheeler", 870000);
System.out.println("Vehicle Loan amount is: " + user.issueVehicleLoan());
System.out.println("Vehicle Insurance amount is: " + user.getInsurance());
scanner.close();
}
}