chaibs

targil4-tax

Dec 20th, 2017
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class tax {
  4.  
  5.     public static void main(String[] args) {
  6.         int sal = 0, kids = 0, tax = 0;
  7.         char ma, residence;
  8.  
  9.         Scanner s = new Scanner(System.in);
  10.  
  11.         System.out.println("Please enter your salary:");
  12.         sal = s.nextInt();// input users salary
  13.  
  14.         System.out.println("Are you a minor or an adult?(M-for minor, A-for adult)");
  15.         ma = s.next().charAt(0);// input user minor or adult
  16.  
  17.         if (sal < 5000) {// checking if users salary is less then 5000
  18.             tax = 0;
  19.         } else if (sal > 5000 && sal < 10000) {// checking if users salary is between 5000 to 10000
  20.             tax = (int) (sal * 0.1);
  21.         } else if (sal > 10000 && sal < 15000) {// checking if users salary is between 10000 to 15000
  22.             tax = (int) (sal * 0.35);
  23.         } else {// checking if users salary is higher then 15000
  24.             tax = (int) (sal * 0.5);
  25.         }
  26.  
  27.         if (ma == 'A' || ma == 'a') {// checking if user is a minor or an adult
  28.  
  29.             System.out.println("Are you living close to Goliver? (Y-for yes, N-for No)");
  30.             residence = s.next().charAt(0);// input if user living next to Goliver
  31.  
  32.             if ((residence == 'Y' || residence == 'y') && sal > 10000) {// checking if user is living next to Goliver or
  33.                                                                         // not and if users salary is higher then 10000
  34.                 tax -= 400;
  35.             }
  36.  
  37.             System.out.println("Please enter how many kids you have:");
  38.             kids = s.nextInt();// input how many kids the user have
  39.  
  40.             if (kids > 3) {// checking if user have more then 3 kids
  41.                 tax -= 900;
  42.                 System.out.println("You need to pay to IRS " + tax + " ILS");// output
  43.             } else {// if user have less then 3 kids
  44.                 tax -= (kids * 300);
  45.                 System.out.println("You need to pay to IRS " + tax + " ILS");// output
  46.             }
  47.         } else if (ma == 'M' || ma == 'm') {// checking if user is a minor or an adult
  48.             tax = (int) (0.5 * tax);
  49.             System.out.println("You need to pay to IRS " + tax + " ILS");// output
  50.         } else {// message if wrong input for minor or adult
  51.             System.out.println("Please check your input.. You need to enter M-for minor or A-for adult");// output
  52.         }
  53.  
  54.     }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment