Here is my code it is for an application that does multiplication quizes.
/*
Chapter 4: Programming Assignment 1
Programmer: Richard Mullikin
Date: February 19, 2010
Filename: Quiz.java
Purpose:
*/
import java.io.*;
public class Quiz
{
public static void main (String[] args ) throws IOException
{
//Declaring variables
int multiplier;
int correct;
boolean done = false;
//Opening messages
System.out.println("\t\tWelcome to the Multiplication Quiz");
System.out.println("");
try
{
//Calling the user-defined methods
multiplier = getNumber();
correct = takeQuiz(multiplier);
System.out.println("\t\tYou got "+correct+ " correct!" );
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"Your entry was not valid.","Error",JOptionPane.INFORMATION_MESSAGE);
}
public static int getNumber() throws IOException
{
//Declaring variables
BufferedReader dataIn = new BufferedReader (new InputStreamReader(System.in));
String inputData;
int multiplier;
//Get a value from user
System.out.print("Enter the multiplication table you wish to practice: ");
inputData = dataIn.readLine();
multiplier = Integer.parseInt( inputData );
//Return a value to main
return multiplier;
}
public static int takeQuiz(int multiplier) throws IOException
{
//Declaring variables
BufferedReader dataIn = new BufferedReader (new InputStreamReader(System.in));
String inputData;
int answer;
int count = 0;
int correct = 0;
while ( count <= 12)
{
//Display question and get answer
System.out.println( "What is "+count + " times " + multiplier +"?" );
inputData = dataIn.readLine();
answer = Integer.parseInt( inputData );
if (answer == count * multiplier)
{
System.out.println("\tCorrect!");
correct = correct + 1;
}
else
{
System.out.println("\tIncorrect");
}
count = count + 1;
}
return correct;
}
the errors I get back is this.
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:36: illegal start of expression
public static int getNumber()
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:36: illegal start of expression
public static int getNumber()
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:36: ';' expected
public static int getNumber()
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:36: ';' expected
public static int getNumber()
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:52: illegal start of expression
public static int takeQuiz(int multiplier) throws IOException;
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:52: illegal start of expression
public static int takeQuiz(int multiplier) throws IOException;
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:52: ';' expected
public static int takeQuiz(int multiplier) throws IOException;
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:52: '.class' expected
public static int takeQuiz(int multiplier) throws IOException;
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:52: ';' expected
public static int takeQuiz(int multiplier) throws IOException;
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:52: illegal start of expression
public static int takeQuiz(int multiplier) throws IOException;
^
C:\Users\Richard & Julie\Desktop\School Stuff\Java Programing\Quiz.java:82: reached end of file while parsing
}
^
11 errors
Tool completed with exit code 1
They seem to be all focused on lines 36 and 52. These were not the lines I had to modify either, they came from the data files. Anysugestions?

New Topic/Question
Reply




MultiQuote








|