Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class InsuranceCalculator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double taxes;
- System.out.println("Enter your salary in BGN");
- int salary = scanner.nextInt();
- System.out.println("Enter your age");
- int age = scanner.nextInt();
- //if salary less than 3000BGN
- if(salary < 3000 && salary > 0 && age > 0){
- // how older is
- if(age < 55) taxes = (salary / 100) * (20 + 17);
- else if(age >= 55 && age < 60) taxes = (salary / 100) * (13 + 13);
- else if(age >= 60 && age < 65) taxes = (salary / 100) * (7.5 + 9);
- else taxes = (salary / 100) * (5 + 7.5);
- System.out.printf("Total you pay: %.2f BGN",taxes);
- }
- //Input validation
- else if(age <= 0) System.out.println("Incorrect input");
- else if(salary <= 0) System.out.println("Incorrect input");
- //if a large salary
- else {
- taxes = (salary / 100) * (20 + 20);
- System.out.printf("Total you pay: %.2f BGN",taxes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement