Hi guys/gals,
I am student at University of Phoenix. I am not here to have you do my homework, I know this is not the place for that. I do need help though. I am trying to work through this course an really learn something.
Many of you ar probably familiar with the Payroll program part 2. I completed last week's pat one and did well. For this week's part of the program is to modify the previous week's assignment to continue to requesting employee information until the user enters stop as the employee name. It is also suppose to check that the hourly rate and number of hours worked are positive numbers. If either the hourly rate or the number of hours worked is not a positive value, the application should prompt the user to enter a positive amount.
I asked my insructor for some guidance to which he said all you have to do is add a while loop to keep prompting for the employee information and then a couple of if statements to ensure that only positive numbers are entered.
Easy enough but I think it is reiterating what the syllabus tells me to do. I am not sure where in the code the comments are suppose to go or where the while loop goes. Can someone point me in the right direction? Please see my code below.
import java.util.Scanner;
public class WeeklyPay {
public static void main(String args[]) {
// Input using the scanner class
Scanner in = new Scanner(System.in);
// get the Name
System.out.printf("Enter the employee's name:\n");
String name = in.nextLine();
// Rate input
System.out.printf("Enter the employee's hourly rate in US dollars:\n");
double rate = in.nextDouble();
// Hours
System.out.printf("Enter the number of hours worked for the week:\n");
double hours = in.nextDouble();
// Output the result
System.out.printf("Employee: " + name + "\n");
System.out.printf("Pay: $%.2f", rate*hours);
}
}