所以我在java中有这个简单的代码。但是当我尝试按照代码中所写的“再次使用该程序”时,它总是会跳过第一个条目,即输入名称。我该如何解决?
这是代码:
import java.util.Scanner;
public class Try{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int salary;
String name, perform;
int choice = 1;
do{
System.out.println("Enter your name:");
name=sc.nextLine();
System.out.println("Enter your performance:");
perform=sc.nextLine();
System.out.println("Enter your salary:");
salary=sc.nextInt();
System.out.println("Name: "+name);
System.out.println("Performance: " + perform);
System.out.println("Salary:" + salary);
System.out.println("Do you want to use the program again?\n[1]Yes\n[2]No");
choice=sc.nextInt();
}while (choice < 2);
}
}