Question

In: Computer Science

For this assignment, you must follow directions exactly. Create a P5 project in Eclipse then write...

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:

  1. Instantiate a single Scanner object to read console input.
  2. Declare doubles for the gross salary, interest income, and capital gains.
  3. Declare an integer for the number of exemptions.
  4. Declare doubles for the total income, adjusted income, federal tax, and state tax.
  5. Print the prompt shown below and ask the user for their gross salary.
  6. The gross salary represents dollars, which can be entered with or without decimal points.
  7. Print the prompt shown below and ask the user for the number of exemptions.
  8. The number of exemptions is an integer.
  9. Print the prompt shown below and ask the user for their interest income.
  10. The interest income represents dollars, which can be entered with or without decimal points.
  11. Print the prompt shown below and ask the user for their capital gains income.
  12. The capital gains represents dollars, which can be entered with or without decimal points.
  13. Perform the calculation of federal total income, as shown in the Formula section.
  14. Perform the calculation of the federal adjusted income, as shown in the Formula section.
  15. Perform the calculation of the federal total tax, as shown in the Formula section.
  16. Perform the calculation of the state income tax, as shown in the Formula section.
  17. Print out the total income, adjusted income, total tax, and state tax.
  18. You may use integer or floating point for the computations.
  19. The output should always report exactly 2 digits after the decimal, so use System.out.printf.
  20. Your program should be accurate to within $0.01.
  21. Use variables to store everything, don't try to do all the calculation in a print statement!
  22. Do not hard code values, we will test your program with different values.
  23. You do not need to handle a negative adjusted income.
  24. The example below shows four lines of user input (in blue font), with prompts, followed by four lines of program output (in black font).
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

Solutions

Expert Solution

/**************************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:)


Related Solutions

For this coding exercise, you need to create a new Java project in Eclipse and finish...
For this coding exercise, you need to create a new Java project in Eclipse and finish all the coding in Eclipse. Run and debug your Eclipse project to make sure it works. Then you can just copy and paste the java source code of each file from Eclipse into the answer area of the corresponding box below. The boxes will expand once you paste your code into them, so don’t worry about how it looks J All data members are...
Assignment Write each of the following functions. The function header must be implemented exactly as specified....
Assignment Write each of the following functions. The function header must be implemented exactly as specified. Write a main function that tests each of your functions. Specifics In the main function ask for a filename and fill a list with the values from the file. Each file should have one numeric value per line. This has been done numerous times in class. You can create the data file using a text editor or the example given in class – do...
Female Reproductive Physiology Directions: For this assignment, you are to create a chart that depicts all...
Female Reproductive Physiology Directions: For this assignment, you are to create a chart that depicts all the regulatory events during the female reproductive cycle. You will need to include the hormonal events of the hypothalamus, the anterior pituitary and the ovary. In addition, you will need to add sections for follicular development and uterine proliferation. Be sure to label all sections, structures, hormones andphases.
Final Project Elementary Statistics Directions: Please follow each step below. Upload your completed assignment as a...
Final Project Elementary Statistics Directions: Please follow each step below. Upload your completed assignment as a Word document in Canvas. Step 1: Choose one research question from the list below: 1. Does viewing a movie versus reading a book about the movie allow students to score higher on assessments related to the literature? 2. Does drinking caffeine affect students' performance on tests? 3. What is more important to college-bound high school seniors when choosing a major: interest in the subject,...
Using eclipse IDE, create a java project and call it applets. Create a package and call...
Using eclipse IDE, create a java project and call it applets. Create a package and call it multimedia. Download an image and save it in package folder. In the package, create a java applet where you load the image. Use the drawImage() method to display the image, scaled to different sizes. Create animation in Java using the image. In the same package folder, download a sound. Include the sound in your applets and make it repeated while the applet executes....
Directions: Create a research project that you could conduct, if you had an unlimited budget with...
Directions: Create a research project that you could conduct, if you had an unlimited budget with which to work.    Tasks: 1.Discuss the topic coping with the death of another person 2.Create a question to which you would be interested in discovering an answer. 3.Select one of the three classic developmental designs, either a cross-sectional design, a longitudinal design, or a sequential design, that you would use to conduct your research.    4.State who you would have as participants in...
Follow the UML diagram and directions on the attached file to create a RectangularPrism class and...
Follow the UML diagram and directions on the attached file to create a RectangularPrism class and a RectangularPrismDemo class. --------------------------------------------------------------------------------------------------------------------------------------- RectangularPrism            - length: double       - width: double       - height: double + RectangularPrism() + RectangularPrism(l:double,w:double, h:double) + setLength(l:double):void + setWidth(w:double):void + setHeight(h:double):void +getLength():double +getWidth():double +getHeight():double +getVolume():double +getSurfaceArea():double +toString():String --------------------------------------------------------------------------------------------------------------------- Create a RectangularPrism class in its own file based on the UML Create a separate RectangularPrismDemo Class file to demonstrate your class by doing the following: Create two prisms,...
This is very important. You must follow my instructions exactly. There are 9 questions. Each question...
This is very important. You must follow my instructions exactly. There are 9 questions. Each question requires you to answer TRUE or FALSE followed by an explanation. If you do not do this I will interpret your answer as I see it, so the word TRUE or FALSE is critical as a start to each question. The second important thing is to put each answer below the relevant question, not all at the end of the exam. So, you will...
Directions Follow the Written Assignment Guidelines in this and all other assignments in this course. Below...
Directions Follow the Written Assignment Guidelines in this and all other assignments in this course. Below are the directions specific to this assignment. Jane Elliott created prejudice among the students in her elementary school classroom in one week. Watch the footage of her classic 1968 demonstration: A Class Divided (Links to an external site.)Links to an external site. The study starts at about 3:20 minutes into the episode and runs until about 17:50 if you want to be selective in...
Directions of assignment: - Create an array of words of size 10. - Prompt the User...
Directions of assignment: - Create an array of words of size 10. - Prompt the User to enter the 10 integers. Populate the array with the integers as they are entered. - You MUST use indexed addressing to traverse through the array. - Determine the maximum and the minimum values contained within the array and print them out. Can you see what I am doing wrong here, the last part (to find the min and max) I can't seem to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT