我的jsp页面上的浏览器没有输出?

时间:2015-06-28 18:52:56

标签: java jsp

second.jsp

public static void main(String[] args) throws InterruptedException
{
    //creates the Scanners needed
    Scanner szAnswer = new Scanner(System.in);
    Scanner szPlayAgain = new Scanner(System.in);

    //declares the variables for the answers
    String szFirstAnswer;
    String szSecondAnswer;
    String szThirdAnswer;

    //declares a variable for the score
    int iScore = 0;

    //declares a variable for whether or not the user wants to keep playing
    String szRestart;

    //creates a do while loop, keeps going as long as the user wants to play
    do {
        //tells the user that only one word answers are needed
        System.out.println("Only one word answers are needed!");

        //first question
        //Asks the question and collects the input
        System.out.println("Question 1:");
        System.out.print("Which Ancient Greek god was said to be the god of the sky? ");
        szFirstAnswer = szAnswer.next();

        //converts the answer to a format with the first letter upper case and the rest lower case
        szFirstAnswer = szFirstAnswer.substring(0,1).toUpperCase() + szFirstAnswer.substring(1);
        szFirstAnswer = szFirstAnswer.substring(0,1) + szFirstAnswer.substring(1).toLowerCase();

        //prints out the converted response
        System.out.println("You said: " + szFirstAnswer);

        //if the answer was Zeus, the print out correct and add 1 to the score
        if (szFirstAnswer.equals("Zeus")) {
            System.out.println("Correct!");
            iScore++;
        }
        //if the answer was not Zeus, print out a message with the correct answer
        else {
            System.out.println("Wrong! The correct answer was: Zeus");
        }

        //creates a line break
        System.out.println();


        //second question
        //Asks the question and collects the input
        System.out.println("Question 2:");
        System.out.print("Which team has won the most FA Cups since the competition started? ");
        szSecondAnswer = szAnswer.next();

        //converts the answer to a format with the first letter upper case and the rest lower case
        szSecondAnswer = szSecondAnswer.substring(0,1).toUpperCase() + szSecondAnswer.substring(1);
        szSecondAnswer = szSecondAnswer.substring(0,1) + szSecondAnswer.substring(1).toLowerCase();

        //prints out the converted response
        System.out.println("You said: " + szSecondAnswer);

        //if the answer was Arsenal, the print out correct and add 1 to the score
        if (szSecondAnswer.equals("Arsenal")) {
            System.out.println("Correct!");
            iScore++;
        }//end if

        //if the answer was not Arsenal, print out a message with the correct answer
        else {
            System.out.println("Wrong! The correct answer was: Arsenal");
        }//end else

        //creates a line break
        System.out.println();


        //third question
        //Asks the question and collects the input
        System.out.println("Question 3:");
        System.out.print("What is the currency of Japan? ");
        szThirdAnswer = szAnswer.next();

        //converts the answer to a format with the first letter upper case and the rest lower case
        szThirdAnswer = szThirdAnswer.substring(0,1).toUpperCase() + szThirdAnswer.substring(1);
        szThirdAnswer = szThirdAnswer.substring(0,1) + szThirdAnswer.substring(1).toLowerCase();

        //prints out the converted response
        System.out.println("You said: " + szThirdAnswer);

        //if the answer was Yen, the print out correct and add 1 to the score
        if (szThirdAnswer.equals("Yen")) {
            System.out.println("Correct!");
            iScore++;
        }//end if

        //if the answer was not Yen, print out a message with the correct answer
        else {
            System.out.println("Wrong! The correct answer was: Yen");
        }//end else

        //creates a line break
        System.out.println();

    }while (szRestart.equals("Y"));//end while

    //prints a thank you message to the screen
    System.out.println("Thanks for Playing!");

    //closes the scanners
    szAnswer.close();
    szPlayAgain.close();

}//end main

浏览器中的数据库没有输出.. 请给我建议我哪里出错...

0 个答案:

没有答案
相关问题