Java program an income tax program that 1. generate a random number of people in the range of (1-15); 2. ask the user to enter the amount of taxable income for each person, and then displays the tax due; 3. display the people with max value of taxes on the screen.

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter8: Working With Advanced Functions
Section: Chapter Questions
Problem 2.8CP
icon
Related questions
Question

Java program

an income tax program that

1. generate a random number of people in the range of (1-15);
2. ask the user to enter the amount of taxable income for each person, and then displays the tax due;
3. display the people with max value of taxes on the screen.
Income
Amount of tax
Not over $750
$750-$2500
$2500-$5000
$5000-$8000
Over $8000
1% of income
$7.5 plus 2% of amount over $750
$82.5 plus 4% of amount over $2500
$142.50
$230.00
plus 5% of amount over $5000
plus%6 of amount over $8000
Transcribed Image Text:Income Amount of tax Not over $750 $750-$2500 $2500-$5000 $5000-$8000 Over $8000 1% of income $7.5 plus 2% of amount over $750 $82.5 plus 4% of amount over $2500 $142.50 $230.00 plus 5% of amount over $5000 plus%6 of amount over $8000
Expert Solution
program

import java.util.*;
public class Main
{
 public static void main(String[] args) {
      int maximum=15;
      int minimum=1;
      double max_tax=0;
      Scanner sc=new Scanner(System.in);
      int random_number=(int) (Math.random()*(maximum - minimum)) + minimum;//for generating random number
      int[] a=new int[random_number];// to store income values 
      double[] tax=new double[random_number];// to store tax
      //to read read input and calculate tax based on the slab
      for(int i=0;i<random_number;i++)
      {
          System.out.println(" enter the taxable income");
          a[i]=sc.nextInt();
          if(a[i]<750)
          {
              tax[i]=a[i]*0.01;
          }
          else if(a[i]>=750 && a[i]<2500)
          {
              tax[i]=7.5+(a[i]-750)*0.02;
          }
          else if(a[i]>=2500 && a[i]<5000)
          {
              tax[i]=82.5+(a[i]-2500)*0.04;
          }
          else if(a[i]>=5000 && a[i]<8000)
          {
              tax[i]=142.50+(a[i]-5000)*0.05;
          }
          else
          {
              tax[i]=230.00+(a[i]-8000)*0.06;
          }
          
          
          System.out.println("the tax amount for "+i+1+" person is "+ tax[i]);
          if(tax[i]>max_tax)
          {
              max_tax=tax[i];
          }
          
      }
      System.out.println("the max tax amount is "+ max_tax);

 }
}

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage