Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class IRS {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int salary, numOfChild;
- boolean isAdult, isNearGulliver, isParent;
- float tax;
- System.out.println("Please enter your payroll: ");
- salary = s.nextInt();
- // Calculating the taxes in accordance with the salary
- switch(salary / 5000) {
- case 0:
- tax = 0;
- break;
- case 1:
- tax = salary * 0.1f;
- break;
- case 2:
- tax = salary * 0.35f;
- break;
- default:
- tax = salary * 0.5f;
- break;
- }
- System.out.println("Please enter 'true' if you are over 18 years old, or 'false' otherwise: ");
- isAdult = s.nextBoolean();
- System.out.println("Please enter 'true' if you have children, or 'false' otherwise: ");
- isParent = s.nextBoolean();
- // If not an adult and not a parent
- if(!(isAdult || isParent)) {
- tax *= 0.5f;
- } else {
- System.out.println("Please enter 'true' if you live near Gulliver, or 'false' otherwise: ");
- isNearGulliver = s.nextBoolean();
- if(isNearGulliver && salary < 10000) {
- tax -= 400; // Calculating discount in taxes
- }
- if(isParent) {
- System.out.println("Please enter the number of children you have: ");
- numOfChild = s.nextInt();
- tax = numOfChild >= 3 ? tax - 900 : tax - (300 * numOfChild); // Calculating discount in taxes
- }
- }
- if(tax >= 0) {
- System.out.println("You have to pay " + tax + " ILS to the IRS.");
- } else {
- System.out.println("IRS should pay you " + (-tax) + "ILS!"); // Negative taxes
- }
- }
- }
Add Comment
Please, Sign In to add comment