0

can anyone help me to explain on how to solve this question? thank you

a simple program that allows to enter the details of employees in order to prepare for their salary. The system will only need to accept the employee’s name and salary. Then the number of different denomination of notes will be shown on screen. Sample run: Record #1: Enter Employee’s Name: James Dean Enter Employee’s Salary ($): 2,564.20 Continue (Y/N)? Y Record #2: Enter Employee’s Name: Dana Miller Enter Employee’s Salary ($): 1,832.70 Continue (Y/N)? y Record #3: Enter Employee’s Name: Sorry, the name cannot be empty. Enter Employee’s Name: May Chan Enter Employee’s Salary ($): A Sorry, salary is invalid. Enter Employee’s Salary ($): 2,299.40 Continue (Y/N)? N Result Name Salary James Dean 2564.20 Dana Miller 1832.70 May Chan 2299.40 Total 6696.30

9th Feb 2017, 7:12 AM
newbie
3 Antworten
+ 2
So you'll need to create a loop that runs until the input from the Continue (Y/N)? is equal to n or N. I would suggest a while or do while loop. You'll need to get user input in the loop for the questions that are asked. (Scanner) Go ahead a make 1 for each question. As per the 3rd record you'll need to do some checking to at least make sure that their name isn't an empty String and that their salary is of the proper type. Parse the input string and remove the comma(s) then check to make sure it is of type Double or Float. In either instance of invalid input you'll need to re-ask the question. This means that they should also be in a loop of their own (a while loop or recursion could be used for this) until the proper input is received along with an if statement to output the error before asking again. Then when the input is properly completed and the user enters n or N the info is output in a particular format. This means that those values had to be saved in a relational fashion. I would think something like a Dictionary, map, hash map to store these. Where the name would be the key for their salary. You could then easily iterate over them in a loop. I would think a for each loop for this, getting the key value pair to use in the loop. Try breaking each part within the main loop into its own method and just calling those methods alone from within the main loop. I hope that helps. Good learning exercise. Which is why I didn't just code it out for you, but if you need tidbits of help just ask.
9th Feb 2017, 7:51 AM
ChaoticDawg
ChaoticDawg - avatar
0
Thanks ChaoticDawg.
23rd Feb 2017, 1:44 PM
newbie