请帮忙干活的时候,我试图让这个工作,但我不断收到错误,主要是一些错误与阵列
C:\Users\Carter\OneDrive\Documents\Programs\Assignment7\Assignment7.java:26: error: '.class' expected
Quiz myQuiz = new Quiz(int count, String name);
^
C:\Users\Carter\OneDrive\Documents\Programs\Assignment7\Assignment7.java:26: error: ';' expected
Quiz myQuiz = new Quiz(int count, String name);
^
C:\Users\Carter\OneDrive\Documents\Programs\Assignment7\Assignment7.java:26: error: not a statement
Quiz myQuiz = new Quiz(int count, String name);
^
C:\Users\Carter\OneDrive\Documents\Programs\Assignment7\Assignment7.java:26: error: ';' expected
Quiz myQuiz = new Quiz(int count, String name);
^
4 errors
任何帮助,将不胜感激!我发布的只是驱动程序,如果需要,我也可以发布类定义!提前致谢!
//Driver program
import java.util.*;
public class Assignment7
{
public static void main (String[] args) {
Quiz myQuiz = new Quiz(int count, String name);
Scanner console = new Scanner (System.in);
String choice;
char command;
// print the menu
printMenu();
do
{
// ask a user to choose a command
System.out.println("\nPlease enter a command or type ?");
choice = console.next().toLowerCase();
command = choice.charAt(0);
switch (command)
{
case 'n': //asks and prints the quiz size and name of student
System.out.println("n [Create a new Quiz]");
System.out.println("[Input the size of quizzes]: ");
scores.length = console.nextInt();
System.out.print(scores.length);
System.out.println("[Input the name of student]: ");
name = console.nextString();
System.out.print(name);
break;
case 'a': // adds a score
System.out.println("a [Add a score]: ");
numAdd = console.nextInt();
System.out.print(numAdd);
break;
case 'd': // deletes a score
System.out.println("d [Delete a score]: ");
numDelete = console.nextInt();
System.out.print(numDelete);
break;
case 'p': //prints the information
System.out.println("p [Print the information]: ");
System.out.println(name);
System.out.println(scores);
break;
case '?':
printMenu();
break;
case 'q':
break;
default:
System.out.println("Invalid input");
}
} while (command != 'q');
} //end of the main method
public static void printMenu()
{
System.out.print("\nCommand Options\n"
+ "-----------------------------------\n"
+ "n: Create a new data\n"
+ "a: Add a score\n"
+ "d: Delete a score\n"
+ "p: Print the information\n"
+ "?: display the menu again\n"
+ "q: Quit this program\n\n");
} // end of the printMenu method
}
'new Quiz(int count,String name);' - 你需要在基本的方法调用语法的教训。 – August 2014-11-14 22:19:13
那么我在第一学期的java课,所以... 而且,这不是调用一个方法,即设置我将使用使用Quiz类的方法对象。 – Cdiehl77 2014-11-14 22:19:49
如何定义“测验”?你想让它成为你提到的数组吗? – DSlomer64 2014-11-14 22:21:49