-
Notifications
You must be signed in to change notification settings - Fork 0
/
watchprice.java
29 lines (26 loc) · 889 Bytes
/
watchprice.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
class WatchPriceCalculator {
public String getWatchPrice(String watchType, int age, String gender) {
double costPrice;
double profitPercentage;
double gst;
if (watchType.equals("Titan")) {
costPrice = 7999;
profitPercentage = 12.5;
gst = 7.5;
} else if (watchType.equals("Rolex")) {
costPrice = 10999;
profitPercentage = 13.5;
gst = 12.5;
} else {
return "Invalid Watch Type";
}
double billAmount = costPrice + costPrice * profitPercentage / 100 + costPrice * gst / 100;
if (gender.equals("female")){
billAmount -= billAmount * 2 / 100;
}
if (age >= 60){
billAmount -= billAmount * 3 / 100;
}
return "The total bill amount is"+String.format("%.2f", billAmount);
}
}