Description
Description: The following workshop lets you practice basic java coding techniques, creating classes, methods, inheritance, polymorphism. Task 1: (2D array Challenge) Use a two-dimensional array to solve the following problem: • A company has o Four salespeople (1 to 4) who sell five different products (1 to 5). • Once a day, each salesperson passes in a slip for each type of product sold. Each slip contains the following: 1. The salesperson number 2. The product number 3. The total dollar value of that product sold that day • Thus, each salesperson passes in between 0 and 5 sales slips per day. • Assume that the information from all the slips for last month is available. Write an application that will read all this information for last month’s sales and summarize the total sales by salesperson and by product. • All totals should be stored in the two-dimensional array sales. • After processing all the information for last month, display the results in tabular format, with each column representing a salesperson and each row representing a particular product. Cross-total each row to get the total sales of each product for last month. • Cross-total each column to get the total sales by salesperson for last month. • Your output should include these cross-totals to the right of the totaled rows and to the bottom of the totaled columns. Hints: • I would recommend creating two classes for this problem at the minimum o SalesSlip to manage the class behaviors ▪ getPerson() ▪ getProduct() ▪ getValue() • 2D array to represent products and salesperson JAC – 444 Fall 2021 • For last month sales slips use random — for example create 100 sale slip records as single dimension array and store. This output is generated using random numbers no user input required. Task 2: (Class Practice) The Canadian federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: • single filers • married filing jointly or qualified widow(er) • married filing separately • head of household. The tax rates vary every year. If you are, for example say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%, so, your total tax is $1,082.50. Design a class named IncomeTax to contain the following instance data fields (Chose the data fields types on your own): 1. filingStatus: One of the four tax-filing statuses: • 0—single filer • 1— married filing jointly or qualifying widow(er) • 2—married filing separately • 3—head of household. 2. Use the constants • SINGLE_FILER(0) • MARRIED_JOINTLY_OR_QUALIFYING_WIDOW(ER) (1) • MARRIED_SEPARATELY (2) • HEAD_OF_HOUSEHOLD (3) to represent the statuses. JAC – 444 Fall 2021 3. A double-dimension array (You decide the type of it) named intervals: Stores the tax intervals/ brackets for each filing status. 4. A single-dimension array (You decide the type) named rates: Stores the tax rates for each interval. 5. A variable taxableIncome: Stores the taxable income. 6. Provide the getter and setter methods for each data field and the getIncomeTax() method that returns the tax. 7. Provide a no-arg constructor. 8. Provide the overloaded constructor IncomeTax(filingStatus, intervals, rates, taxableIncome). Write a program that prompt the user with a simple menu system of three choices: • Compute personal income Tax • Print the tax tables for taxable incomes (with range) • Exit ❖ With choice one your program should prompt the user to enter the filing status and taxable income and compute the tax. ❖ With choice two your program should use the IncomeTax class to print the 2001 and 2009 tax tables for taxable income from (ask the user to input the amount) to (ask the user to input the amount) with intervals of $1,000 for all four statuses. The tax rates for the year 2001 and 2009 are given in Tables below. Table 1: 2001 Canadian Federal Personal Tax Rates Tax Rate Single Married Filing Jointly or Qualifying Widow(er) Married Filing Separately Head of House Hold 15% Up to – $27,050 Up to – $45,200 Up to $22,600 Up to – $36,250 27.5% $27,051 – $65,550 $45,201 – $109,250 $22,601 – $54,625 $36,251 – $93,650 30.5% $65,551-$136,750 $109,251 – $166,500 $54,626 – $83,250 $93,651 – $151,650 35.5% $136,751-$297,350 $166,501 – $297,350 $83,251 – $148,675 $151,651 – $297,350 39.1% $297,351 + $297,351 + $148,676+ $297,351+ Table 2: 2009 Canadian Federal Personal Tax Rates Marginal Tax Rate Single Married Filing Jointly or Qualifying Widow(er) Married Filing Separately Head of House Hold 10% $0 – $8,350 $0 – $16,700 $0 – $8,350 $0 – $11,950 15% $8,351 – $33,950 $16,701 – $67,900 $8,351 – $33,950 $11,951 – $45,500 25% $33,951-$82,250 $67,901 – $137,050 $33,951 – $68,525 $45,501 – $117,450 28% $82,251-$171,550 $137,051 – $208,850 $68,526 – $104,425 $117,451 – $190,200 33% $171,551-$372,950 $208,851 – $372,950 $104,426 – $186,475 $190,201 – $372,950 35% $372,951 + $372,951 + $186,476 + $372,951 + For each filing status there are six tax rates. Each rate is applied to a certain amount of taxable income. For example, of a taxable income of $400,000 for single filers, $8,350 is taxed at 10%, (33,950 – 8,350) at 15%, (82,250 – 33,950) at 25%, (171,550 – 82,250) at 28%, (372,950 – 171,550) at 33%, and (400,000 – 372,950) at 35%. Continue to the next page…. JAC – 444 Fall 2021 Possible output screen shots: With choice 1: With choice 2: Roll to the next page for output Continue to the next page… 0 – single filer 1 – married jointly or qualifying widow(er) 2 – married separately 3 – head of household) Enter the filing status: 0 Enter the Taxable Income: $20000 Tax is: $2582.50 JAC – 444 Fall 2021 Continue to the next page… Enter the amount From: $50000 Enter the amount To: $60000 2001 tax tables for taxable income from $50,000 to $60,000 ———————————————————————————- Taxable Single Married Joint Married Head of Income or Qualifying Separate a House Widow(er) ———————————————————————————- 50000 10368.75 8100.00 10925.00 9218.75 51000 10643.75 8375.00 11200.00 9493.75 52000 10918.75 8650.00 11475.00 9768.75 53000 11193.75 8925.00 11750.00 10043.75 54000 11468.75 9200.00 12025.00 10318.75 55000 11743.75 9475.00 12311.25 10593.75 56000 12018.75 9750.00 12616.25 10868.75 57000 12293.75 10025.00 12921.25 11143.75 58000 12568.75 10300.00 13226.25 11418.75 59000 12843.75 10575.00 13531.25 11693.75 60000 13118.75 10850.00 13836.25 11968.75 2009 tax tables for taxable income from $50,000 to $60,000 ——————————————————————————— Taxable Single Married Joint Married Head of Income or Qualifying Separate a House Widow(er) ——————————————————————————— 50000 9846.50 7296.70 10398.50 8506.50 51000 10116.50 7566.70 10668.50 8776.50 52000 10386.50 7836.70 10938.50 9046.50 53000 10656.50 8106.70 11208.50 9316.50 54000 10926.50 8376.70 11478.50 9586.50 55000 11196.50 8646.70 11748.50 9856.50 56000 11466.50 8916.70 12018.50 10126.50 57000 11736.50 9186.70 12305.50 10396.50 58000 12006.50 9456.70 12605.50 10666.50 59000 12276.50 9726.70 12905.50 10936.50 60000 12546.50 9996.70 13205.50 11206.50 60000 11187.50 15205.70 11187.50 9852.50 JAC – 444 Fall 2021 Workshop Header /********************************************** Workshop # Course: – Semester Last Name: First Name: ID: Section: