Write a program the meets the conditions as described below. You will need to di
ID: 3537387 • Letter: W
Question
Write a program the meets the conditions as described below. You will need to display a menu of four options that the user can choose from. Make sure that you code includes you name, class, section, date and a brief description as a comment header. Also be sure that your code includes comments. The menu portion should be implemented using a Switch statement. You may use conditional statements for each individual component of the program. Be sure that you code is properly formatted and that all output is clear, descriptive and neat.
Sample Menu:
//////////////////////////////////////////////////////////////////////////////
Welcome to My Program
1. Display Student Data (formatted)
2. Draw shapes
3. Calculate weighted Grade
/////////////////////////////////////////////////////////////////////////////
User Option 1:
For option one, ask the user to input the following information for a hypothetical student: First Name, Last Name, GPA, Major and Graduation year. Next use printf, to display the following information based on the order below for parts a, b and c. The words below represent placeholders for possible variable names. You will need to display the actual data, based on the input data in the specified order below.
a. LastName FirstName, GPA ,GPA ,GPA , Graduation year ,Major, Major (There should be 10 spaces between each variable when displayed. Show the first GPA value with 2 decimal places, the 2nd with 3 decimal places, and the 3rd gpa value with 5 decimal places)
b. GPA, GPA, Major, Graduation year ,Graduation Year (left aligned, with 15 spaces between each variable when displayed)
c. FirstName ,GPA ,Major ,Graduation Year (with 15 spaces between each variable when displayed)
User Option 2:
Ask the user if the way to display shape 1, 2 or 3. Use IF/Else here to manage the submenu for option 2. Display the following shapes depending on the user%u2019s choice. You do need to use any loops, you can use regular print statements.
Shape:1 Shape:2 Shape:3
+===+===+ ************* 2222222222
| | | ************* 4444444444
| | | ************* 6666666666
+===+=== ************* 8888888888
| | | *************
| | | *************
+===+===+ *************
User Option 3:
Option 3 calculates a student%u2019s grade based on a weighted score. Assume that the final grade is based on Final Score = 10% * test1_score + 10% * test2_score + 30% * final_exam + 40% * labs + 10% quiz
You will need to ask the user for their scores in each category. (assume that the max value for each category is 100 points)
Your program should display their final score, their letter grade and an encouraging message depending on the letter grade. (For exam, if they earned an %u201CA%u201D, print %u201CGreat Job!%u201D)
User Option 4 %u2013 Computing Taxes:
The United States federal income tax is calculated based on filing status and taxable income. There are four filling statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. The table below shows the rates for 2002. If you are, say single with a taxable income of $10,000, the first $6,000 is taxed at 10% and the other $4,000 is taxed at 15%, so your tax is $1,200.
Tax Rate
Single Filers
Married Filing jointly
or qualifying widow/ widower
Married filing separately
Head of Household
10%
Up to 6,000
Up to 12,000
Up to 6,000
Up to 10,000
15%
6,001 %u2013 27,950
12,001 %u2013 46,700
6,001 %u2013 23,350
10,001 %u2013 37,450
27%
27,951 - 67,700
46,701 %u2013 112,850
23,351 %u2013 56,425
37,451 %u2013 96,700
30%
67,701 %u2013 141,250
112,851 %u2013 171,950
56,426 %u2013 85,975
96,701 %u2013 156,600
35%
141,251 %u2013 307,050
171,951 %u2013 307,350
85,976 %u2013 153,525
156,601 %u2013 307,050
38.6%
307,051 or more
307,051 or more
153,526 or more
307,051 or more
You are to write a program to compute personal income tax. Your program should prompt the user to enter the filing status and taxable income and compute the tax (which should be displayed back to the user). Enter 0 for single filers, 1 for married filing jointly, 2 for married filing separately and, 3 for head of household.
Your program computes the tax for the taxable income based on the filing status. The filing status can be determined using if statements outlined as follows:
if (status == 0) {
//compute tax for single filers
}
else if (status == 1) {
//compute tax for married filing jointly
}
else if (status == 2){
// compute tax for married filing separately
}
else if (status ==3){
//compute tax for head of household
}
else {
//display wrong status %u2013 error message
}
For each filing status there are six taxes rates as shown in the table. Each rate is applied to a certain amount of taxable income. For example, of a taxable income of $400,000 for single filers, $6,000 is taxed at 10%, (27,950 %u2013 6,000) at 15%, (67,700- 27,950) at 27%, (141,250 %u2013 67,700) at 35%, and (400,000 %u2013 307,050) at 38.6%.
The following partial solution to compute taxes for single filers to help complete this portion of the exercise is listed below:
Tax Rate
Single Filers
Married Filing jointly
or qualifying widow/ widower
Married filing separately
Head of Household
10%
Up to 6,000
Up to 12,000
Up to 6,000
Up to 10,000
15%
6,001 %u2013 27,950
12,001 %u2013 46,700
6,001 %u2013 23,350
10,001 %u2013 37,450
27%
27,951 - 67,700
46,701 %u2013 112,850
23,351 %u2013 56,425
37,451 %u2013 96,700
30%
67,701 %u2013 141,250
112,851 %u2013 171,950
56,426 %u2013 85,975
96,701 %u2013 156,600
35%
141,251 %u2013 307,050
171,951 %u2013 307,350
85,976 %u2013 153,525
156,601 %u2013 307,050
38.6%
307,051 or more
307,051 or more
153,526 or more
307,051 or more
Explanation / Answer
I have already given you the solution of first 3 halves.
Add a case 4 to your switch for tax calculator
Here is the code
case 4 : System.out.println("You selected option 4");
System.out.println("This is United States federal income tax office. Lets calculate your tax");
System.out.println("What is your filling status");
System.out.println("Press 0 for single fillers");
System.out.println("Press 1 for married filing jointly");
System.out.println("Press 2 for married filing seperately");
System.out.println("Press 3 for head of household");
int optionFiller = scanner.nextInt();
System.out.println("Enter your taxable income");
double taxableIncome = scanner.nextDouble();
double tax = 0;
if (optionFiller == 0)
{
if (taxableIncome <=6000)
{
tax = 0.10 * taxableIncome;
}
else if ( tax <= 27950)
{
tax = (0.10 * 6000) + (0.15 * (taxableIncome- 6000));
}
else if (tax <= 67700)
{
tax = (0.10 * 6000) + (0.15 * (27950-6000)) + (0.27 * (taxableIncome- 27950)) ;
}
else if (tax <= 141250)
{
tax = (0.10 * 6000) + (0.15 * (27950-6000)) + (0.27 * (67700- 27950)) + (0.30 * (taxableIncome- 67700));
}
else if (tax <= 307050)
{
tax = (0.10 * 6000) + (0.15 * (27950-6000)) + (0.27 * (67700- 27950)) + (0.30 * (141250- 67700))+ (0.35 * (taxableIncome - 141250));
}
else
{
tax = (0.10 * 6000) + (0.15 * (27950-6000)) + (0.27 * (67700- 27950)) + (0.30 * (141250- 67700))+
(0.35 * (307050 - 141250)) + (0.386 * (taxableIncome- 307050));
}
}
else if (optionFiller == 1)
{
if (taxableIncome <=12000)
{
tax = 0.10 * taxableIncome;
}
else if ( tax <= 46700)
{
tax = (0.10 * 12000) + (0.15 * (taxableIncome- 12000));
}
else if (tax <= 112850)
{
tax = (0.10 * 12000) + (0.15 * (46700-12000)) + (0.27 * (taxableIncome- 46700)) ;
}
else if ( tax <= 171950)
{
tax = (0.10 * 12000) + (0.15 * (46700-12000)) + (0.27 * (112850- 46700)) + (0.30 * (taxableIncome- 112850));
}
else if ( tax <= 307050)
{
tax = (0.10 * 12000) + (0.15 * (46700-12000)) + (0.27 * (112850- 46700)) + (0.30 * (171950- 112850))+ (0.35 * (taxableIncome - 171950));
}
else
{
tax = (0.10 * 12000) + (0.15 * (46700-12000)) + (0.27 * (112850- 46700)) + (0.30 * (171950- 112850))+
(0.35 * (307050 - 171950)) + (0.386 * (taxableIncome- 307050));
}
}
else if (optionFiller == 2)
{
if (taxableIncome <=6000)
{
tax = 0.10 * taxableIncome;
}
else if ( tax <= 23350)
{
tax = (0.10 * 6000) + (0.15 * (taxableIncome- 6000));
}
else if ( tax <= 56425)
{
tax = (0.10 * 6000) + (0.15 * (23350-6000)) + (0.27 * (taxableIncome- 23350)) ;
}
else if ( tax <= 85975)
{
tax = (0.10 * 6000) + (0.15 * (23350-6000)) + (0.27 * (56425- 23350)) + (0.30 * (taxableIncome- 56425));
}
else if (tax <= 153525)
{
tax = (0.10 * 6000) + (0.15 * (23350-6000)) + (0.27 * (56425- 23350)) + (0.30 * (85975- 56425)) + (0.35 * (taxableIncome - 85975));
}
else
{
tax = (0.10 * 6000) + (0.15 * (23350-6000)) + (0.27 * (56425- 23350)) + (0.30 * (85975- 56425)) +
(0.35 * (153525 - 85975)) + (0.386 * (taxableIncome- 153525));
}
}
else if (optionFiller == 3)
{
if (taxableIncome <=10000)
{
tax = 0.10 * taxableIncome;
}
else if ( tax <= 37450)
{
tax = (0.10 * 10000) + (0.15 * (taxableIncome- 10000));
}
else if (tax <= 96700)
{
tax = (0.10 * 10000) + (0.15 * (37450- 10000))+ (0.27 * (taxableIncome- 37450)) ;
}
else if ( tax <= 156600)
{
tax = (0.10 * 10000) + (0.15 * (37450- 10000))+ (0.27 * (96700- 37450)) + (0.30 * (taxableIncome- 96700));
}
else if (tax <= 307050)
{
tax = (0.10 * 10000) + (0.15 * (37450- 10000))+ (0.27 * (96700- 37450))
+ (0.30 * (156600- 96700)) + (0.35 * (taxableIncome - 156600));
}
else
{
tax = (0.10 * 10000) + (0.15 * (37450- 10000))+ (0.27 * (96700- 37450))
+ (0.30 * (156600- 96700)) + (0.35 * (307050 - 156600)) + (0.386 * (taxableIncome- 307050));
}
}
else {
System.out.println("Enter a valid option");
}
System.out.println("Total tax You have to pay is : $ "+tax);
break;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.