//Neel Patel
//Friday October 9th, 2009
/*This is a quiz program that will ask the user 10 questions. the user will answer
* these questions and will be scored out of 10.*/
class Quiz
{
public static void main (String args[])
{
//Instructions
System.out.println("instructions");
System.out.println(" ");
System.out.println("1. You wll be asked ten questions through out the quiz.");
System.out.println("2. The first question will appear, you will have to answer that question for the next question to appear.");
System.out.println("3. When you answer the last question you will be told your score.");
System.out.println(" ");
System.out.println("welcome to the basketball quiz.");
// question 1
System.out.println(" ");
System.out.println("Question 1. ");
System.out.println("How tall is a basketball hoop? ");
System.out.println("Type in Answer here:");
String Question1= In.getString();
if (Question1.equalsIgnoreCase("10 Feet"))
{
System.out.println("Correct!");
}
else
{
System.out.println("you got this questions wrong");
}
// question 2
System.out.println(" ");
System.out.println("Question 2. ");
System.out.println("Who invented basketball? ");
System.out.println("Type in Answer here:");
String Question2= In.getString();
if (Question2.equalsIgnoreCase("James Naismith "))
{
System.out.println("Correct!");
}
else
{
System.out.println("you got this questions wrong");
}
} }
this is my program that iam writing. I want to make a counter that will keep score of every question that is answered right and then display it to the user after the questions are finished. i tried using this..
int Score=0
Score=Score+1
but it did not work for the 2nd question but works for the 3rd ... it gives me an error .. is there another way i can do this or am i dooing something wrong?