Hey, I am trying to use this program, it is supposed to ask one multiple choice question of the user and get the response. For some reason it will not work for me. I am using Ready to Program by HoltSoft. Please help me.

import java.awt.*;
import java.applet.*;
import java.io.*;

public class Quiz_Show extends Applet
{
    public static void main (String args[])
    {
        InputStreamReader istream = new InputStreamReader (System.in);
        BufferedReader bufRead = new BufferedReader (istream);
        String First_Answer = "";
        int score = 0;
        System.out.println ("Welcome to my quiz show.");
        System.out.println ("Please enter the letter of the answer for each question.");
        System.out.println ("Here is the first question.");
        System.out.println ("What is the largest country in the world?");
        System.out.println ("A-Canada");
        System.out.println ("B-Russia");
        System.out.println ("C-USA");
        System.out.println ("D-China");
        while (First_Answer.equalsIgnoreCase (""))
        {
            try
            {
                System.out.println ("Please answer with a, b, c, or d");
                First_Answer = bufRead.readLine ();
            }
            catch (IOException err)
            {
                System.out.println ("Error reading line");
            }
        }
        if (First_Answer.equals ("b"))
        {
            System.out.println ("Good job, that is correct!");
            score = score + 15;
        }
        else
        {
            System.out.println ("Sorry, that answer is incorrect.");
        }
    }
}

When I try to run it it comes up "Error Message=The specified module could not be found.
Error Code=126"

Thanks in advance for any hep you can provide.

Recommended Answers

All 5 Replies

Sounds like a question for the producers of your IDE, as that is not a Java error.

However, do you want an Applet or a Stand-alone app?

You've extended Applet, but written a Stand-Alone, so which is it?

I ran it, and it works on my IDE, it has to be your IDE. I agree with masijade though, you have Applet extended but you've coded for console IO.

Thank you masijade and ragedsparrow , since reading what you have said I have unistalled and reinstalled my IDE and now the program seems to he working. As for the other stuff you have noted, I am just beginning to learn Java and was instructed by my teacher to make a Java applet that is modelled after a quiz show that I made in Turing, and this is what I managed to do. Also thank you for the quick responses, I really appreciate it.

It's all good, glad I could help a little.

Ok, the program now is working for me, but now today i have tried to add in my second question. The applet works but it won't let me input a answer for the second question, it just uses my answer from the first question. How do I fix this?

import java.awt.*;
import java.applet.*;
import java.io.*;

public class Quiz_Show extends Applet
{
    public static void main (String args[])
    {
        InputStreamReader istream = new InputStreamReader (System.in);
        BufferedReader bufRead = new BufferedReader (istream);
        String Answer = "";
        int score = 0;
        System.out.println ("Welcome to my quiz show.");
        System.out.println ("Please enter the letter of the answer for each question and press enter.");
        System.out.println ("Here is the first question.");
        System.out.println ("What is the largest country in the world?");
        System.out.println ("A-Canada");
        System.out.println ("B-Russia");
        System.out.println ("C-USA");
        System.out.println ("D-China");
        while (Answer.equalsIgnoreCase (""))
        {
            try
            {
                System.out.println ("Please answer with a, b, c, or d");
                Answer = bufRead.readLine ();
            }
            catch (IOException err)
            {
                System.out.println ("Error reading line");
            }
        }
        if (Answer.equals ("b"))
        {
            System.out.println ("Good job, that is correct!");
            score = score + 15;
        }
        else
        {
            System.out.println ("Sorry, that answer is incorrect.");
            score = score - 5;
        }
        System.out.println ("Here is the second question.");
        System.out.println ("What is 32+(4x9)?");
        System.out.println ("A-32");
        System.out.println ("B-324");
        System.out.println ("C-36");
        System.out.println ("D-68");
        while (Answer.equalsIgnoreCase (""))
        {
            try
            {
                System.out.println ("Please answer with a, b, c, or d");
                Answer = bufRead.readLine ();
            }
            catch (IOException err)
            {
                System.out.println ("Error reading line");
            }
        }
        if (Answer.equals ("d"))
        {
            System.out.println ("Good job, that is correct!");
            score = score + 15;
        }


        else
        {
            System.out.println ("Sorry, that answer is incorrect.");
            score = score - 5;
        }

    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.