Could some one look at this program and let me know if the Scanner object and variables are defined and defined correctly? And make suggestions on how to fix it if it is wrong. I also want to know if my validations are correct for employee, hours, and rate are correct, if not suggestions on how to fix them would be extremely helpful. I feel a little lost on this java programming stuff even with all the text and websites that I have read through.
import java.util.Scanner; // scanner for input
public class Payrollprogram
{
// main method begin program execution
public static void main( String args[] )
{
// scanner to obtain user input
Scanner input = new Scanner( System.in );
// scanner employee object
{
Employee = newEmployee(name,hours,rate);
}
}
//display welcome message for user
public void displayMessage()
{
System.out.printf( "Welcome to payroll for\n%s!\n\n",
getEmployeeName() );
} // end displayMessage method
//get employee name
{
System.out.println( "Enter employee name: " );
}
{
employeeName = input.nextLine();
while (employee.equals(""))
{
System.out.print( "Enter proper employee name: " );
employee = Input.nextString();
// continue
}
if(employee==stop)
{
System.exit();
}
} // end get employee name
// hours worked
{
do
{
System.out.print( "How many hours did " + employee + " work? ");
hours = Input.nextDouble();
if(hours < 0)
{
System.out.print( "Enter proper number of hours: ");
hours = Input.nextDouble();
}
hours_valid = true;
} while (hours < 0);
}// end hours worked class
// pay rate
{
do
{
System.out.print( "How much does " + employee + " make per hour? ");
rate = Input.nextDouble();
if (rate < 0)
{
System.out.print( "Enter proper number for rate: ");
rate = Input.nextDouble();
}
rate_valid = true;
} while (hours < 0);
}// end pay rate class
// calculate pay total
{
pay = rate * hours;
NumberFormat fmt = NumberFormat.getCurrencyInstance();
System.out.println("\n" + employee + " worked for " + hours
+ " hours at " + fmt.format(rate) + "/hr; paycheck = "
+ fmt.format(pay));
}
} // end Payroll class
I am very unsure of my work because this is my first program. Please help.