//Payroll Program Part 2
package payrollprogrampart2;
/**
*
* @author Zach
*/
import java.util.Scanner;
public class PayrollProgramPart2 {
public static void main(String args [])
{ System.out.println("Welcome to Zach's Payroll Program");
Scanner input = new Scanner( System.in );
String employeeName;
System.out.print("What is the employee's name?");
boolean stop = false;
while (!stop)
System.out.print("Enter Employee's name or stop to exit program:");
String empName = input.nextLine();
if ( empName.equals ("stop"))
{
System.out.println("Program Exited");
stop = true;
int number1;// hourly rate
int number2;// total hours
int sum;// total weekly pay
System.out.print("Enter hourly rate:");
number1 = input.nextInt();
while (number1 <= 0)
System.out.print( "Hourly rate must be a positive number." );
number1 = input.nextInt ();
System.out.print( "Enter total hours: " );
number2 = input.nextInt();
while (number2 <= 0)
System.out.print("Hours worked must be a postive number.");
number2 = input.nextInt();
sum = number1 * number2;
System.out.printf("Sum is %d\n",sum);
}
zach1280
0
Newbie Poster
Recommended Answers
Jump to PostThat error means that you reached the end of file without closing some brackets. You still need the main method bracket and the class bracket.
Regards
Jump to PostThere are some issues also in your code.Because i fixed your code and compiled it.But when it starts to run only output the Welcome message.Therefore check the code again..And post the question also here.That'll be easy to understand the code..
Jump to PostHi Zach!
I found out some mistakes in your code!
First, plz review your code:while (!stop) System.out.print("Enter Employee's name or stop to exit program:"); String empName = input.nextLine(); if ( empName.equals ("stop")) { System.out.println("Program Exited"); stop = true; int number1;// hourly rate int number2;// total hours …
All 9 Replies
zach1280
0
Newbie Poster
AurosGamma
0
Newbie Poster
zach1280
0
Newbie Poster
pro_learner
0
Junior Poster
.:n'tQ-boy:.
0
Light Poster
.:n'tQ-boy:.
0
Light Poster
pro_learner
0
Junior Poster
pro_learner
0
Junior Poster
zach1280
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.