Facebook
From Putrid Cassowary, 4 Years ago, written in Java.
This paste is a reply to Re: Re: 18 answer 4 NoamDadon from Commodious Water Vole - view diff
Embed
Download Paste or View Raw
Hits: 114
  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.         int tax1 = 10;
  10.         int tax2 = 20;
  11.         int tax3 = 30;
  12.         int tax4 = 40;
  13.         int tax5 = 50;
  14.  
  15.         double income = 0;
  16.         double tax = 0;
  17.         System.out.println("Please enter your name: ");
  18.         String name = input.next();
  19.         System.out.println("Please enter your income: ");
  20.         income = input.nextInt();
  21.         double temp = income;
  22.  
  23.         if (income > 0) {
  24.             temp = income / tax1;
  25.             if (income > 23_000) {
  26.                 temp += (income - 23_000) / tax2;
  27.                 if (income > 46_000) {
  28.                     temp += (income - 74_000) / tax3;
  29.                     if (income > 120_000) {
  30.                         temp += (income - 100_000) / tax4;
  31.                         if (income > 220_000) {
  32.                             temp += (income - 220_000) / tax5;
  33.                         }
  34.                     }
  35.                 }
  36.             }
  37.         }
  38.         System.out.println("the tax you need to pay is : " + temp);
  39.     }
  40.  
  41. }