In: Computer Science
For this assignment, you must follow directions exactly. Create a P5 project in Eclipse then write a class P5 with a main method, and put all of the following code into the main method:
Salary: 92768.54 Exemptions: 8 Interest: 1234.50 Gains: 4400.99 Total Income: $93404.03 Adjusted Income: $84404.03 Total Tax: $15033.13 State Tax: $5486.26
/**************************P5.java***************************/
import java.util.Scanner;
/**
* The Class P5.
*/
public class P5 {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
Scanner scan = new
Scanner(System.in);
double grossSalary, interestIncome,
capitalGains;
int numberOfExemptions;
double totalIncome, adjustedIncome,
federalTax, stateTax, totalTax;
System.out.print("Salary: ");
grossSalary =
scan.nextDouble();
System.out.print("Exemptions:
");
numberOfExemptions =
scan.nextInt();
System.out.print("Interest:
");
interestIncome =
scan.nextDouble();
System.out.print("Gains: ");
capitalGains =
scan.nextDouble();
totalIncome = grossSalary +
interestIncome + capitalGains;//calculate using your formula
adjustedIncome = totalIncome *
numberOfExemptions;//calculate using your formula
federalTax = totalIncome *
.15;//calculate using your formula
stateTax = totalIncome *
.20;//calculate using your formula
totalTax = federalTax +
stateTax;
System.out.printf("Total Income:
$%.2f\n", totalIncome);
System.out.printf("Adjusted Income:
$%.2f\n", adjustedIncome);
System.out.printf("Total Tax:
$%.2f\n", totalTax);
System.out.printf("State Tax:
$%.2f\n", stateTax);
scan.close();
}
}
/*******************output******************/
Salary: 92768.54
Exemptions: 8
Interest: 1234.50
Gains: 4400.99
Total Income: $98404.03
Adjusted Income: $787232.24
Total Tax: $34441.41
State Tax: $19680.81
Please let me know if you have any doubt or modify the answer, Thanks:)