-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarTest.java
More file actions
27 lines (17 loc) · 876 Bytes
/
CarTest.java
File metadata and controls
27 lines (17 loc) · 876 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
public class CarTest{
public static void main(String[] args){
Car car1 = new Car("Rolls Royce", "2020", 988000000.00);
Car car2 = new Car("Escalade", "2022", 220000000.00);
System.out.printf("Car 1 model: %s; year: %s; price: %.2f%n",
car1.getModel(), car1.getYear(), car1.getPrice());
System.out.printf("Car 2 model: %s; year: %s; price: %.2f%n",
car1.getModel(), car2.getYear(), car2.getPrice());
System.out.printf("Car Price after applying discount");
car1.setPrice(car1.getPrice() * (1 - 0.05));
car2.setPrice(car2.getPrice() * (1 - 0.07));
System.out.printf("Car 1 model: %s; year: %s; price: %.2f%n",
car1.getModel(), car1.getYear(), car1.getPrice());
System.out.printf("Car 2 model: %s; year: %s; price: %.2f%n",
car1.getModel(), car2.getYear(), car2.getPrice());
}
}