我编译没有错误,但是我可以完成第一个循环没有问题.然而,第二次绕过它将提示分区名称但是员工数量的提示确实如此.所以我最终看到输入部门名称:输入员工人数:
不知道为什么会发生这种情况,但是在看的时候我看不到任何不合适的地方.
如果您看到我出错的地方,您可以指向行号或代码串.
谢谢.
import java.util.Scanner;
public class PayRoll {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String name;
int employees;
double salary;
while(true) {
System.out.print("Enter Division Name: ");
name = input.nextLine();
if(name.equalsIgnoreCase("stop")) {
break;
}else {
System.out.print("Enter Number of Employees: ");
employees = input.nextInt();
while(employees <= 0) {
System.out.print("Number of Employees Must be Greater than 0, Please Re-enter: ");
employees = input.nextInt();
}
System.out.print("Enter Average Salary: ");
salary = input.nextDouble();
while(salary <= 0) {
System.out.print("Average …Run Code Online (Sandbox Code Playgroud)