Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class InsuranceCalculator {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. double taxes;
  9.  
  10. System.out.println("Enter your salary in BGN");
  11. int salary = scanner.nextInt();
  12.  
  13. System.out.println("Enter your age");
  14. int age = scanner.nextInt();
  15.  
  16. //if salary less than 3000BGN
  17. if(salary < 3000 && salary > 0 && age > 0){
  18.  
  19. // how older is
  20. if(age < 55 && age > 0) taxes = (salary / 100) * (20 + 17);
  21. else if(age >= 55 && age < 60) taxes = (salary / 100) * (13 + 13);
  22. else if(age >= 60 && age < 65) taxes = (salary / 100) * (7.5 + 9);
  23. else taxes = (salary / 100) * (5 + 7.5);
  24.  
  25. System.out.printf("Total you pay: %.2f BGN",taxes);
  26. }
  27.  
  28. //Input validation
  29. else if(age <= 0) System.out.println("Incorrect input");
  30. else if(salary <= 0) System.out.println("Incorrect input");
  31.  
  32. //if a large salary
  33. else {
  34. taxes = (salary / 100) * (20 + 20);
  35. System.out.printf("Total you pay: %.2f BGN",taxes);
  36. }
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement