0

can anyone help me to solve this? how do i print out this result?

Enter Employee’s Name: Sorry, the name cannot be empty. Enter Employee’s Name: Jacky Enter Employee’s Salary ($): A Sorry, salary is invalid. Enter Employee’s Salary ($): 2,509.40 Continue (Y/N)? Y Enter Employee's Name:

24th Feb 2017, 9:33 AM
newbie
2 Respuestas
+ 1
thanks~ i will try
24th Feb 2017, 11:46 AM
newbie
0
I would use a couple methods. a getName() method and a salary() method I would loop until my condition is met inside of my methods.. public String getName(){ String newname=""; while(newname==""){ System.out.println("Enter Your Name-"); Scanner in = new Scanner(); newname=in.nextLine(System.in); } return newname; Just an example.. I didn't test this I just wanted to give you an idea of how I might loop it. you can work out the specifics. I would do similar for a getSalary() method. then I would wrap it all in another loop. boolean run=true; while(run){ getName(); getSalary(); Scanner s = new Scanner(); System.out.println("Continue Y/N"); String again=s.nextLine(System.in); if(again=="N"){ run=false; } } Again, the specifics of the code are up to you, This is just an example of how I would layout some loops if I wanted to repeat some code.
24th Feb 2017, 10:07 AM
LordHill
LordHill - avatar