Facebook
From Unique Marmoset, 3 Years ago, written in Java.
This paste is a reply to 18 answer 2 NoamDadon from Scanty Motmot - view diff
Embed
Download Paste or View Raw
Hits: 104
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         final int tax1 = 10;
  10.         final int tax2 = 20;
  11.         final int tax3 = 30;
  12.         final int tax4 = 40;
  13.         final int tax5 = 50;
  14.         final int step1 = 23_000;
  15.         final int step2 = 46_000;
  16.         final int step3 = 74_000;
  17.         final int step4 = 120_000;
  18.        
  19.         double income = 0;
  20.         double tax = 0;
  21.         System.out.println("Please enter your name: ");
  22.         String name = input.next();
  23.         System.out.println("Please enter your income: ");
  24.         income = input.nextInt();
  25.         double temp = income;
  26.  
  27.         if (income > 0) {
  28.             temp = income / tax1;
  29.             if (income > step1) {
  30.                 temp += (income - step1) / tax2;
  31.                 if (income > step2) {
  32.                     temp += (income - step2) / tax3;
  33.                     if (income > step3) {
  34.                         temp += (income - step3) / tax4;
  35.                         if (income > step4) {
  36.                             temp += (income - step4) / tax5;
  37.                         }
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.         System.out.println("the tax you need to pay is : " + temp);
  43.     }
  44.  
  45. }