Quiz program

I'm having a rough go with this program. I am getting major errors and I can't get to the first one to figure out what I am doing wrong.
Please help:

import javax.swing.JOptionPane;
import java.util.Scanner;

public class MainP2 {
//Reference to QuizUI
QuizUI ui;

public static void main(String[] args) {
    MainP2 app = new MainP2();

    JOptionPane.showInputDialog(null, "Andres Miera     Program:Take a Quiz n/" +
    "The object of this program is to make a working quiz.", JOptionPane.INFORMATION_MESSAGE);

    JOptionPane.showInputDialog("There are 20 questions about cartoons and cartoon " +
    "characters, both old and new.n/ Please answer each question by typing the name of the cartoon n/" +
    "or cartoon character, remembering to capitalize the first letter.", JOptionPane.INFORMATION_MESSAGE);


public MainP2() {
    ui = new QuizUI();

public class Quiz {

    // Variables for use in quiz all set as private
    private String keepGoing;
    private String name;
    private String theme;
    private String answer;
    private String question;
    private String correctAnswer;
    private String incorrectAnswer;
    private double correct = 0;
    private double wrong = 0;
    private String[] listQuestion = new String[19];
    private String[] cartoonName = new String[19];
    // Indices for shuffling
    private int []index  = {0, 1, 2 ,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};

    // Arrays for the quiz          
    listQuestion[0] = "What cartoon features a cat and mouse in sometimes violent altercations? ";
    listQuestion[1] = "Which is one of the most well know Saturday morning cartoon shows" +
    " featuring characters like Bugs Bunny and Daffy Duck? ";
    listQuestion[2] = "What cartoon is based on a comic book superhero squad" +
    " that later inspired movies with the same name? ";
    listQuestion[3] = "Willlmaaaaa!! ";
    listQuestion[4] = "Which cartoon featured a character named Battle Cat? ";
    listQuestion[5] = "Which cartoon has 2 hungry bears as the main characters? ";
    listQuestion[6] = "Which cartoon had a the catch phrase 'Hello Nurse!!' when the" + 
    " characters would see an attractive character on the show? ";
    listQuestion[7] = "This cartoon featured younger, more modern versions of classic" +
    " Saturday morning cartoon characters? ";
    listQuestion[8] = "Which chartoon character was a talking, mystery solving goof? ";
    listQuestion[9] = "Which character was voiced by a now infamous celebrity? ";
    listQuestion[10] = "This character was a small dog that while slow, always came out on top. ";
    listQuestion[11] = "The original grumpy cat... ";
    listQuestion[12] = "This is a cult cartoon favorite featuring a superhero talking dog. ";
    listQuestion[13] = "Which cartoon is one of the longest running tv shows in history? ";
    listQuestion[14] = "Which cartoon features a lesser known orange cat? ";
    listQuestion[15] = "This cartoon featured physics defying swimming in a giant safe of gold coins. ";
    listQuestion[16] = "Which is a 90's cartoon featuring lots of cats? ";
    listQuestion[17] = "Spinach was this character's go to for strength. ";
    listQuestion[18] = "Which character could destroy a tree in no-time flat? ";
    listQuestion[19] = "Which cartoon featured lab mice plotting to take over the world? ";

    // This is the answer list of cartoon names     
    cartoonName[0] = "Tom and Jerry";
    cartoonName[1] = "Looney Tunes";
    cartoonName[2] = "X-Men";
    cartoonName[3] = "The Flinstones";
    cartoonName[4] = "He-Man";
    cartoonName[5] = "Yogi Bear";
    cartoonName[6] = "Tiny Toons Adventures";
    cartoonName[7] = "Animaniacs";
    cartoonName[8] = "Scooby Doo";
    cartoonName[9] = "Fat Albert";
    cartoonName[10] = "Droopy";
    cartoonName[11] = "Garfield";
    cartoonName[12] = "Underdog";
    cartoonName[13] = "The Simpsons";
    cartoonName[14] = "Heathcliff";
    cartoonName[15] = "Duck Tales";
    cartoonName[16] = "Thundercats";
    cartoonName[17] = "Popeye";
    cartoonName[18] = "Woody Woodpecker";
    cartoonName[19] = "Pinky and the Brain";

    // Default constructor to initialize variables and call initial shuffle
    public Quiz(){
        String name;
        String theme;
        String answer;
        String question;
        double correct;
        double wrong;


    // Methods to be set
    public void setUserInput(String name, String theme) {
        return name, theme;


    public void setAnswer(String answer) {
        Answer = answer;

    // Get methods
    // Returns String that lets the user know whether the answer is right or wrong and gives the right answer
    public String getRightWrong() {
        if (answer.compareto(cartoonName))
            return String correctAnswer;
            return String incorrectAnswer;

        String keepGoing;
    // Returns the current question that is being asked
    public String getQuestion() {
        return question;
    // shuffles the indices
    private void shuffle() {
        (int i = 0; i < listQuestion.length; i++) {
    int index = (int)(Math.random() * listQuestion.length);
    String question = listQuestion[0];
    listQuestion[0] = listQuestion[index];
    listQuestion[index] = question;


    // Determines whether the answer is right or wrong, keeps track of how many of each. Checks to see if all questions
    // have been used and calls shuffle if they have.
    private void checkAnswer() {
        do {
            if (answer.compareTo(cartoonName[i]) == i) {
    return correct;
            } else
                return wrong;
        } while (index[] < 19)

    // Gives the average and the letter grade and creates a String with the information
    public String gradeQuiz() {
        if (correct == 20)
            return String A = ("Congratulations you got an A! 100%");
        else if (correct == 19)
            return String Aminus = ("Congratulations you got an A-! 95%");
        else if (correct== 18)
            return String B = ("You got a B! Good job! 90%");
        else if (correct == 17)
            return String Bminus = ("You got a B-! Good job! 85%");
        else if (correct == 16)
            return String C = ("You were probably studying instead of watching cartoons. You got a C, 80%");
        else if (correct == 15)
            return String Cminus = ("You were probably studying instead of watching cartoons. You got a C, 75");
        else if (correct == 14)
            return String D = ("You know, there are these funny shows called cartoons. You got a D, 70%");
        else if (correct.equalto == 13)
            return String Dminus = ("You know, there are these funny shows called cartoons. You got a D, 65%");
            return String F = ("Were you ever a child? You got an F. Score was 60% or lower");

public class QuizUI(){

// Setting up the User input for the Quiz class
    String name = JOptionPane.showInputDialog("Please enter your name: ", JOptionPane.QUESTION_MESSAGE);
    String theme = JOptionPane.showInputDialog(null, "The theme for this quiz is Cartoons.", JOptionPane.INFORMATION_MESSAGE);
    String answer = JOptionPane.showInputDialog(null, question, QUESTION_MESSAGE);
    String keepGoing = JOptionPane.showConfirmDialog(null, "Would you like to continue?", "Confirm", JOptioPane.YES_NO_OPTION);
    String correctAnswer = JOptioPane.showInputDialog(null, "Correct!", JOptioPane.INFORMATION_MESSAGE);
    String incorrectAnswer = JOptioPane.showInputDialog(null, "Sorry, wrong answer.", JOptioPane.INFORMATION_MESSAGE);


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!