Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class tax {
- public static void main(String[] args) {
- int sal = 0, kids = 0, tax = 0;
- char ma, residence;
- Scanner s = new Scanner(System.in);
- System.out.println("Please enter your salary:");
- sal = s.nextInt();// input users salary
- System.out.println("Are you a minor or an adult?(M-for minor, A-for adult)");
- ma = s.next().charAt(0);// input user minor or adult
- if (sal < 5000) {// checking if users salary is less then 5000
- tax = 0;
- } else if (sal > 5000 && sal < 10000) {// checking if users salary is between 5000 to 10000
- tax = (int) (sal * 0.1);
- } else if (sal > 10000 && sal < 15000) {// checking if users salary is between 10000 to 15000
- tax = (int) (sal * 0.35);
- } else {// checking if users salary is higher then 15000
- tax = (int) (sal * 0.5);
- }
- if (ma == 'A' || ma == 'a') {// checking if user is a minor or an adult
- System.out.println("Are you living close to Goliver? (Y-for yes, N-for No)");
- residence = s.next().charAt(0);// input if user living next to Goliver
- if ((residence == 'Y' || residence == 'y') && sal > 10000) {// checking if user is living next to Goliver or
- // not and if users salary is higher then 10000
- tax -= 400;
- }
- System.out.println("Please enter how many kids you have:");
- kids = s.nextInt();// input how many kids the user have
- if (kids > 3) {// checking if user have more then 3 kids
- tax -= 900;
- System.out.println("You need to pay to IRS " + tax + " ILS");// output
- } else {// if user have less then 3 kids
- tax -= (kids * 300);
- System.out.println("You need to pay to IRS " + tax + " ILS");// output
- }
- } else if (ma == 'M' || ma == 'm') {// checking if user is a minor or an adult
- tax = (int) (0.5 * tax);
- System.out.println("You need to pay to IRS " + tax + " ILS");// output
- } else {// message if wrong input for minor or adult
- System.out.println("Please check your input.. You need to enter M-for minor or A-for adult");// output
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment