//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 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 PostYes be careful when you opens a curly brace.Definitely remember to close that brace as you opened that.
Jump to PostI'll tell you a good programming practice.That's when you opens a curly brace at the same time close it.After that write your code inside that.It won't be persuade to do mistakes.
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.