Untitled
unknown
plain_text
2 years ago
923 B
9
Indexable
public class WaterBillCalculator {
public static double calculateWaterBill(int consumption) {
double total = 0;
if (consumption <= 10) {
total = consumption * 5973;
} else if (consumption <= 20) {
total = 10 * 5973 + (consumption - 10) * 7052;
} else if (consumption <= 30) {
total = 10 * 5973 + 10 * 7052 + (consumption - 20) * 8669;
} else {
total = 10 * 5973 + 10 * 7052 + 10 * 8669 + (consumption - 30) * 15929;
}
double vat = total * 0.05;
double environmentFee = total * 0.10;
return total + vat + environmentFee;
}
public static void main(String[] args) {
int consumption = 7; // số lượng tiêu thụ
double totalBill = calculateWaterBill(consumption);
System.out.println("Tổng cộng tiền thanh toán: " + totalBill);
}
}
Editor is loading...
Leave a Comment