I am making a basic quiz show in Java and I have successfully made the first question. Now when I went ahead and made my second question I encountered this problem. When I run the program there are no errors with it, but it will not let me input a response for the second question and instead just uses my answer for the first question. Please let me know what I can do to 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 ("Time for question two.");
        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 ("Nice work, that's right!");
            score = score + 15;
        }
        else
        {
            System.out.println ("Sorry, that's not the right answer.");
            score = score - 5;
        }
    }
}

Also if you could please let me know how I would get the program to tell the user what their current score is.

Edited 6 Years Ago by luttinj: n/a

Hi
You should reset the Answer variable to empty

Answer="";

;
before the second question to enter the next while loop.
Hope it helps

This question has already been answered. Start a new discussion instead.