I am trying to add the following information to a payroll program I am working on for assignment. Modify 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. Her's what I have.
// Calculate.java
// Calculate weekly pay.
import java.util.Scanner;
public class calculate
{
// main method begins execution of java application
public static void main( String args[] )
{
Scanner input = new Scanner ( System.in );
double hourlyrate;
double hours;
double pay;
//boolean stop = false; // Exit the loop below
//loop until user enters "stop" as the employee name:
// while (!stop)
// create scanner to obtain data from user
System.out.print( "Please enter employee name or stop to exit program: " );
String name = input.nextLine();
while (name != "stop"){
System.out.println("Please enter hourly rate: $" );}
hourlyrate = input.nextDouble();
if (hourlyrate >= 0){
System.out.println("hourly rate is: " + hourlyrate);}
if (hourlyrate <= 0){
System.out.println("Hourly rate must be a positive value. " + "Please enter the hourly rate again: $");}
hourlyrate = input.nextDouble();
System.out.println("Please enter hours worked: ");
hours = input.nextDouble();
if (hours >=0){
System.out.println("hours is: " + hours);}
if (hours <=0){
System.out.println("Hours worked must be a positive value. " + "Please enter the hours worked again: ");}
hours = input.nextDouble();
pay = hourlyrate * hours;
input.nextLine();
System.out.printf("%s pay is $ %.2f\n",name, pay);
// Display employee information
} // end method main
} // end class Calculate