Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 1: Computing Tax Ch 3 Problem Description: The United States federal personal income tax is calculated based on filing status and taxable income. There

Project 1: Computing Tax Ch 3

Problem Description:

The United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 1 shows the rates for 2019. If you are, 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 tax is $1,082.5.

Table 1

2019 U.S. Federal Personal Tax Rates

Marginal Tax Rate

Single

Married Filing Jointly or Qualified Widow(er)

Married Filing Separately

Head of Household

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,525 $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+

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. Enter 0 for single filers, 1 for married filing jointly, 2 for married filing separately, and 3 for head of household.

Here are sample runs of the program:

Sample 1:

Enter the filing status: 0

Enter the taxable income: 100000

Tax is 21720.0

Sample 2:

Enter the filing status: 1

Enter the taxable income: 300339

Tax is 76932.87

Sample 3:

Enter the filing status: 2

Enter the taxable income: 123500

Tax is 29665.5

Sample 4:

Enter the filing status: 3

Enter the taxable income: 4545402

Tax is 1565250.7

Analysis:

(Describe the problem including input and output in your own words.)

Design:

(Describe the major steps for solving the problem.)

Coding: (Copy and Paste Source Code here.

Name your class Taxes

Testing: (Describe how you test this program)

Code Solution:

// import the Scanner class

public class Taxes {

public static void main(String[] args) {

java.util.Scanner input = new java.util.Scanner(System.in);

// Prompt the user to enter filing status

System.out.print(

"Enter the filing status: " +

"(0-single filer, 1-married jointly, " +

"2-married separately, 3-head of household) ");

int status = input.nextInt();

// Prompt the user to enter taxable income

System.out.print("Enter the taxable income: ");

double income = input.nextDouble();

// Compute tax

double tax = 0;

if (status == 0) { // Compute tax for single filers

}

else if (status == 1) { // Compute tax for married file jointly

}

else if (status == 2) { // Compute tax for married separately

}

else if (status == 3) { // Compute tax for head of household

}

else {

System.out.println("Error: Wrong filing status");

System.exit(0);

}

// Display the result

System.out.println("Tax is " + (int)(tax * 100) / 100.0);

}

}

Project 2: Phone keypads (Ch 4)

Problem Description:

The international standard letter/number mapping found on the telephone is shown below:

1

2 ABC

3 DEF

4 GHI

5 JKL

6 MNO

7 PQRS

8 TUV

9 WXYZ

0

Write a program that reads a letter and displays its corresponding digit.

Analysis:

(Describe the problem including input and output in your own words.)

Design:

(Describe the major steps for solving the problem.)

Coding: (Copy and Paste Source Code here. Format your code using Courier 10pts)

Name your main class Keypad

Testing: (Describe how you test this program)

Code Solution:

import java.util.Scanner;

public class Keypad {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter an uppercase letter: ");

char ch = input.nextLine().charAt(0);

int number = 0;

switch (Character.toUpperCase(ch))

{

}

System.out.println("The corresponding number is " + number);

}

}

Project 3: Comparing Loans Ch 5

Problem Description:

Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an increment of 1/8. Here is a sample run:

Loan Amount: 10000

Number of Years: 5

Interest Rate Monthly Payment Total Payment

5% 188.71 11322.74

5.125% 189.28 11357.13

5.25% 189.85 11391.59

...

7.875% 202.17 12129.97

8.0% 202.76 12165.83

Analysis:

(Describe the problem including input and output in your own words.)

Design:

(Describe the major steps for solving the problem.)

Coding: (Copy and Paste Source Code here. Name your program Loan

Testing: (Describe how you test this program. Show sample run)

Hint:

  1. Can you get the first four rows manually? This will help you understand how to compute the numbers mathematically.
  2. Can you write a program to produce the first four rows? This will help you see the pattern.
  3. Can you generalize it in a loop to produce all the rows?
  4. Finally, format the output correctly. Code Solution:

public class Loans {

// Main method

public static void main(String[] args) {

java.util.Scanner input = new java.util.Scanner(System.in);

// Enter loan amount

System.out.print("Enter loan amount, for example 120000.95: ");

double loanAmount = input.nextDouble();

// Enter number of years

System.out.print("Enter number of years as an integer, for example 5: ");

// Convert string to int

int numOfYears = input.nextInt();

// Display the header

for (double annualInterestRate = 5.0; annualInterestRate <= 8.0;

annualInterestRate += 1.0 / 8) {

// Obtain monthly interest rate

// Compute mortgage

double monthlyPayment = loanAmount * monthlyInterestRate /

(1 - (Math.pow(1 / (1 + monthlyInterestRate), numOfYears * 12)));

double totalPayment = monthlyPayment * numOfYears * 12;

// Display results

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

1. Define and explain culture and its impact on your communication

Answered: 1 week ago