This is what I have so far and I have the problem written as a comment on the line I need help with. Any further suggestions would be welcome too. I just need it to end the program when the user enters "stop" as the employee name. Thanks in advance.
package payroll_program_2;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );
float hours;
float rate;
String name;
float total_pay;
System.out.println("Please enter employee name");
name = input.next();
if (stop) //THIS IS WHAT I NEED HELP WITH. I DO NOT KNOW HOW TO WRITE
end program //IT CORRECTLY, SO I JUST TYPED WHAT I NEED IT TO DO.
{
}
System.out.println("Please enter hourly rate");
rate = input.nextFloat();
if (rate <0)
{
System.out.printf("Pay rate cannot be negative");
}
System.out.println("Please enter hours worked");
hours = input.nextFloat();
if (hours <0)
{
System.out.printf("Hours cannot be negative");
}
System.out.println("Employee's total pay for this week");
total_pay = hours*rate;
System.out.printf("The total pay for %s is $%.2f\n", name, total_pay);
}
%nis the best way to place a newline at the end in printf. Generallydoubleis a better choice thanfloatthough it might not matter here.