0

the application below is what i did so far, please give me feedback

the Payroll Program so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate.


import java.util.Scanner; // program uses class Scanner

public class PayrollProgramPart2 //start class PayrollProgramPart2
{
// start method main
public static void main( String args[] )
{
Scanner input = new Scanner( System.in ); //create Scanner to obtain input from CMD

//input commands
System.out.print( "Please enter employee's name: "); //prompt for employee's name
String name = input.nextLine(); //input employee's name
do //do statement for loop
{
//input hourly rate
System.out.print( "Please enter hourly rate: $"); // prompt for hourly rate
double rate = input.nextFloat(); //input hourly rate
while (rate <= 0) //check and loop for equal to or less than 0
{
System.out.print( "Please enter positive hourly rate: $"); //prompt for positve rate
rate = input.nextFloat(); //input hourly rate
} //end while

//input number of hours worked
System.out.print( "Please enter number of hours worked:" );
// prompt for hours worked
double hours = input.nextFloat(); //input hours worked
while (hours <= 0) //check and loop for equal to or less than 0
{
System.out.print( "Please enter positive number of hours: ");
//prompt for positve hours
hours = input.nextFloat(); //input hours worked
} //end while

//calculation commands
double pay = hours*rate; // multiple hours x rate = pay

//output commands
System.out.printf(name +"'s pay this week is: $%.2f\n", pay);
// display employee's name and pay

name = input.nextLine();
System.out.print( "Please enter employee's name or stop to quit: ");
// prompt for employee's name
name = input.nextLine(); //input employee's name or stop
}while (!name.toLowerCase().equals("stop"));
//while statement for loop until name = stop
System.out.print( "Program Terminated" ); // end message
}
// end method main

} // end class PayrollProgramPart2

4
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by verruckt24
0

Use code tags if you need an opinion!

Edited by happygeek: fixed formatting

0

I am clueless about this concept. I am really struggling to get this right. Can you be more specific. This is my first java course.

0

please test it yourself and post the problems that you faced while running...

no Tester available here...

0

the application below is what i did so far, please give me feedback

If it does what you have been asked for, if it works for you. We cannot be more happy. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.