当我尝试运行我的程序时,我收到了几条错误消息,困扰我的主要消息是“错误:变量键盘已在方法 main(String []) 中定义”
我应该在我的程序中不止一次地使用 main(String []) 吗,或者只是在我拥有它的开始时?这里还有什么问题?
这是我的程序的开头:
public static void main(String[]args)
{
String firstName, lastName;
int moviesDownloaded, stateResidency;
double movieCost, netPayment, tax, discount, totalCharge, payment, taxRate;
System.out.println("Enter your first name:");
Scanner keyboard = new Scanner(System.in);
firstName = keyboard.nextString();
System.out.println("Enter your last name:");
Scanner keyboard = new Scanner(System.in);
lastName = keyboard.nextString();
System.out.println("Enter the number of movies downloaded:");
Scanner keyboard = new Scanner(System.in);
moviesDownloaded = keyboard.nextInt();
System.out.println("Enter the cost per movie:");
Scanner keyboard = new Scanner(System.in);
movieCost = keyboard.nextDouble();
System.out.println("Indicate your state of residency. Enter 1 for Mississippi or 2 for any other state.");
Scanner keyboard = new Scanner(System.in);
stateResidency = keyboard.nextInt();