Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

***Program in Java Code*** - The program correctly receives and handles user input - The program correctly calculates the annual salary - The program correctly

image text in transcribed

image text in transcribed

***Program in Java Code***

- The program correctly receives and handles user input

- The program correctly calculates the annual salary

- The program correctly calculates and displays the bonus

- The program effectively uses control structures

- The program properly handles errors

- The program follows directions and standard code conventions

Task: Salary Calculator Write a program that computes the amount of money a person can expect to eam each year over the next 10 years. Ask the user for their current salary. Ask the user for their expected annual increase. This should be entered as a number between 1% and 10%. [you must have error checking here] Ask the user if they expect to receive a bonus. If so, use the Math.random() method to select a random year between year 2 and year 9 where the user will receive a $5,000 bonus. Be sure to include this bonus amount in the starting point for the following year. TIP: Import java.util.Random package for generating random number. You may refer to the java document https://docs.oracle.com/javase/8/docs/apiljava/util/Random.html for more details. If would like to generate a random number between 1 and 10, then you are supposed to write the code- Random num= new Random(); bonusYear = num.nextint(10) + 1; where, bonusYear variable holds the random number generated in between 1 and 10. Similarly, you should modify the above codes to generate a random number in between 2 and 9. Print out a list of the annual expected salary. Each line should contain the "Year N" and the annual salary amount. o If it is the bonus year, concatenate the text "** BONUS YEAR*" to the line. Be sure to check the user's input for invalid entries (e.g. negative numbers). There should be at least 2 checks and appropriate error handling. Attached is a screenshot of the expected output for your convenience: Entered current salary ammount is: 1000 Entered annual increase rate is: 10 Bonus amount is: 5000 Entered bonus year is: 2 Year 1, Annual Salary Amount = 1100.0 **BONUS YEAR** Year 2 Annual Salary Amount = 6200.e Year 3, Annual Salary Amount = 1300.0 Year 4, Annual Salary Amount = 1400.0 Year 5, Annual Salary Amount = 1500.0 Year 6, Annual Salary Amount = 1600.0 Year 7, Annual Salary Amount Year 8, Annual Salary Amount = 1800.0 Year 9, Annual Salary Amount = 1900.0 Year 10, Annual Salary Amount = 2000.e 1700.0 Bonus Question (2 points) In the Salary Calculator task, find out the minimum, highest, and the average salary. Additionally, print the year corresponding to each of the minimum, and highest salary

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_2

Step: 3

blur-text-image_3

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Delete

Answered: 1 week ago