This repository has been archived on 2025-12-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2024-09-20 14:17:13 +03:00

35 lines
1.3 KiB
Java

import java.util.*;
public class Exercise1 {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Units consumed:");
double use = sc.nextDouble();
if (use >= 1 && use <= 100) {
double bill = use * 0.50;
double tax = bill * 0.05;
System.out.println("Bill amount: " + String.format("%.2f", bill));
System.out.println("Tax: " + String.format("%.2f", tax));
System.out.println("Total amount to be paid: " + String.format("%.2f", (bill + tax)));
}
else if (use <= 150) {
double bill = (100 * 0.50 + (use - 100) * 0.75);
double tax = bill * 0.05;
System.out.println("Bill amount: " + String.format("%.2f", bill));
System.out.println("Tax: " + String.format("%.2f", tax));
System.out.println("Total amount to be paid: " + String.format("%.2f", (bill + tax)));
}
else {
double bill = (100 * 0.50 + 50 * 0.75 + (use - 150) * 1.25);
double tax = bill * 0.05;
System.out.println("Bill amount: " + String.format("%.2f", bill));
System.out.println("Tax: " + String.format("%.2f", tax));
System.out.println("Total amount to be paid: " + String.format("%.2f", (bill + tax)));
}
}
}