Question

In: Computer Science

Write a program that determines the income tax rates for a state. Tax rates are based on the salary according to the following table:

in java 

Code Problem 2

Write a program that determines the income tax rates for a state.  Tax rates are based on the salary according to the following table:

0 – 25000 Dollars                    10%

25001 - 50000 Dollars            15%

50001 - 75000 Dollars             20%

Over 75000 Dollars                 35%

Write the program so that it asks the user how many taxpayers should be processed and use the number of taxpayers to control the end of the program. For each taxpayer, you will need to input the taxpayer ID and salary. Use a while loop to validate the taxpayer ID to make sure that it is a number that does not exceed 6 digits in length. Display the following message for an invalid taxpayer ID length: Invalid taxpayerID. Please enter a number that is < 7 digits. Display the taxpayer ID, salary, tax percent, and taxes owed for each taxpayer processed within the loop. Taxes owed is calculated by multiplying the salary * tax % (depending on how you write the program you may need to divide the tax % by 100) when calculating the taxes owed. Use a printf command to display the output in  2 columns and make sure that the percents are formatted with 1 decimal place and the salary and taxes owed are formatted with 2 decimal places. When the program ends, a message of Earn money. Pay taxes. Enjoy life! should be displayed. To help you test your program, below is should run with 4 test cases and no invalid taxpayer IDs:

Be sure to include comments at the top of your program to indicate your name and the name of the program and date.

Please enter the number of taxpayers you want to process.
4


Please enter the taxpayer ID (123456, 234567, 999999 etc.) for taxpayer 1
123456
Please enter the taxpayer salary:
25000


Taxpayer ID                                 123456
Salary                                    25000.00
Tax %                                        10.0
Taxes Owed                                2500.00


Please enter the taxpayer ID (123456, 234567, 999999 etc.) for taxpayer 2
234567
Please enter the taxpayer salary:
50000


Taxpayer ID                                 234567
Salary                                   50000.00
Tax %                                        15.0
Taxes Owed                                7500.00


Please enter the taxpayer ID (123456, 234567, 999999 etc.) for taxpayer 3
345543
Please enter the taxpayer salary:
75000


Taxpayer ID                                 345543
Salary                                   75000.00
Tax %                                        20.0
Taxes Owed                               15000.00


Please enter the taxpayer ID (123456, 234567, 999999 etc.) for taxpayer 4
654321
Please enter the taxpayer salary:
75001


Taxpayer ID                                 654321
Salary                                   75001.00
Tax %                                         35.0
Taxes Owed                               26250.35

Earn money. Pay taxes. Enjoy life!

Solutions

Expert Solution

Code:

import java.util.Scanner;
class tax
{
   public static void main(String[] args)
   {
       int n;
       Scanner scnr=new Scanner(System.in);
       System.out.println("Please enter the number of taxpayers you want to process.");
       n=scnr.nextInt();
       /*Reading no of taxpayers*/
       for (int i=1;i<=4 ;i++ )
       {
           System.out.println("\nPlease enter the taxpayer ID (123456, 234567, 999999 etc.) for taxpayer "+i);
           int taxpayerId=scnr.nextInt();
           /*Reading taxpayer id*/
           while(taxpayerId>999999)
           {
               /*if grater than 6 digits we ask him to enter a number less than 7 digits*/
               System.out.println("Please enter a number <7 digits.");
               taxpayerId=scnr.nextInt();

           }
           System.out.println("Please enter the taxpayer salary:");
           double salary=scnr.nextDouble();
           /*Reading salary*/
           System.out.printf("\nTaxpayer ID\t\t%d",taxpayerId);
           System.out.printf("\nSalary\t\t\t%.2f",salary);
           double tax;
           /*Printing name and salary*/
           if(salary<=25000.0)
           {
               tax=(salary*0.10);
               System.out.print("\nTax%\t\t\t10.0");
               /*If less than 25000 we print tax as 10%*/
              
           }
           else if(salary<=50000.0)
           {
               tax=(salary*0.15);
               System.out.print("\nTax%\t\t\t15.0");
               /*If less than 50000 we print tax as 15%*/
              
           }
           else if(salary<=75000.0)
           {
               tax=(salary*0.20);
               System.out.print("\nTax%\t\t\t20.0");
               /*If less than 75000 we print tax as 20%*/
              
           }
           else
           {
               tax=(salary*0.35);
               System.out.print("\nTax%\t\t\t35.0");
               /*If greater than 75000 we print tax as 35%*/
              
           }
           System.out.printf("\nTaxes Owed\t\t%.2f",tax);
           /*Printing tax*/
       }
       System.out.println("\nEarn money. Pay taxes. Enjoy life!");  
   }
}

Output:

Indentation:


Related Solutions

Based on the following table of the tax rates, what is the average tax rate for a firm with taxable income of $120,000?
Based on the following table of the tax rates, what is the average tax rate for a firm with taxable income of $120,000?Taxable Income ($)Tax Rate0 – 50,00015%50,000 – 75,00025%75,000 – 100,00034%100,000 – 335,00039%39%20%34%25%None of the above
Based on the following table of the tax rates, what is the average tax rate for...
Based on the following table of the tax rates, what is the average tax rate for a firm with taxable income of $120,000? Taxable Income ($) Tax Rate 0 – 50,000 15% 50,000 – 75,000 25% 75,000 – 100,000 34% 100,000 – 335,000 39% A. 20% B. 25% C. 34% D. 39%
Write a Java program to compute the income after tax of an employee based on the...
Write a Java program to compute the income after tax of an employee based on the following rule of tax rate. Assuming the salary is $22000, display the tax and the income after tax. 12% if salary ≥ 25,000 5% if salary < 10,000 Otherwise 8% will be applied Write a Java program to compute and display the sum of the numbers that can be both divisible by 6 and 8 from 1 to 500. Suppose there is a list...
Yanni, a single individual, reports the following information for the tax year. Salary $113,800 State income...
Yanni, a single individual, reports the following information for the tax year. Salary $113,800 State income taxes 11,380 Mortgage interest expense 10,242 Charitable contributions 2,276 Interest income 1,707 Personal exemption 4,050 Click here to access the exemption table. If required, round your answers to the nearest dollar. Compute the following for Yanni. a. Regular taxable income: $ b. AMT base: $ c. Tentative minimum tax: $
The state of Kansas increased income tax rates for higher income households in 2018. For an...
The state of Kansas increased income tax rates for higher income households in 2018. For an individual with high income living in Kansas (and for whom leisure is a normal good), the higher tax rate they now face: will have an unambiguously positive effect on his or her desired work hours. will have an unambiguously negative effect on his or her desired work hours. will have no effect on his or her desired work hours. could have a positive, negative,...
1. What, exactly, is the “State Income Tax (SIT)? What are the various tax rates in...
1. What, exactly, is the “State Income Tax (SIT)? What are the various tax rates in the SIT? Roughly, at what income level does each rate ‘kick in’? 2. Please define the “sales” tax and give me an example of the sales tax and how it applies in a typical transaction. 3. Please define “special taxes and fees” as we discussed them in class, and give an example of how they impact the typical household. 4. How would you improve...
Discuss the classification of individual income taxpayers and the categories of income and tax rates based...
Discuss the classification of individual income taxpayers and the categories of income and tax rates based on latest "Train" Law
Taxation table Income Tax Standard personal income tax rates Income band Taxable amount Rate K1 to...
Taxation table Income Tax Standard personal income tax rates Income band Taxable amount Rate K1 to K39,600 first K39,600 0% K39,601 to 49,200 next K9,600 25% K49,201 to K74,400 next K25,200 30% Over K74,400 37.5% Income from farming for individuals K1 to K39,600 first K39,600 0% Over K39,600 10% Company Income Tax rates On income from manufacturing and other 35% On income from farming 10% Capital Allowances Implements, plant and machinery and commercial vehicles: Wear and Tear Allowance – Standard...
Write a java program using the following instructions: Write a program that determines election results. Create...
Write a java program using the following instructions: Write a program that determines election results. Create two parallel arrays to store the last names of five candidates in a local election and the votes received by each candidate. Prompt the user to input these values. The program should output each candidates name, the votes received by that candidate, the percentage of the total votes received by the candidate, and the total votes cast. Your program should also output the winner...
2018 Form 1040 Gross Income Salary 65,000 Interest Income 1,700 Dividend Income 2,200 State Income Tax...
2018 Form 1040 Gross Income Salary 65,000 Interest Income 1,700 Dividend Income 2,200 State Income Tax Refund 1,100 Schedule C Net Income 3,050 Schedule D Recognized Gain (Loss) 1,200 Gross Income 74,250 Deductions for AGI: Self-employment Tax Deduction 215 Deductions For AGI 215 Adjusted Gross Income 74,035 Deductions from AGI: Medical Expense Deduction 0 Sales Tax Deduction 0 State Income Tax Deduction 1,954 Real Estate Tax Deduction 1,766 Mortgage Interest Expense Deduction 3,845 Credit Card Interest Expense Deduction 0 Charitable...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT