Link to home
Start Free TrialLog in
Avatar of Mick 3009
Mick 3009

asked on

Java basic program code error

Hi,

I am having problem with this quiz basic Java program (see code). This is my first program and any help what be appreciated. Thanks in advance.

public class Quiz{
public static void main (String args[])
{
     System.out.println ("Welcome to the Quiz Game!");
     int ans2=1;    
   
    do{
             
       System.out.println ("The instructions are: you will be given one type of topic,");
       System.out.println ("The topic will have 3 multiple choice questions");
       System.out.println ("If you get one wrong you start from the beginning.");
       System.out.println ("If you get them all right you will win");
 int ans1=Keyboard.readInt();
       
           System.out.println ("First question: How many players are there in 1 football team?");
           System.out.println ("9");
           System.out.println ("10");
           System.out.println ("11");
if((ans1==11)){      
        System.out.println ("Question 2: Which of these teams play in the Premeir League?");
        System.out.println ("press 1 for Juventus");
        System.out.println ("press 2 for Chelsea");
        System.out.println ("press 3 for PSG");
if((ans1==11 & ans1==2));
        System.out.println ("Correct");
        System.out.println ("Question 3: How do you score?");
        System.out.println ("press 1 if by kicking the ball into the net");
        System.out.println ("press 2 if by throwing the ball into the net");
        System.out.println ("press 3 if by kicking the ball outside the terf");
if((ans1==11 & ans1==2 & ans1==1));
            System.out.println ("Correct");
            System.out.println ("Question 4: What shape is the football?");
            System.out.println ("press 1 for cube");
            System.out.println ("press 2 for sphere");
            System.out.println ("press 3 for triangle");
if((ans1==11 & ans1==2 & ans1==1 & ans1==2))
                System.out.println ("Game Over, You Win!");
  else
  System.out.println ("Game Over, You Lose!");}
     
  }while (ans2==1);
 }
}
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Dake
Jeffrey Dake
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mick 3009
Mick 3009

ASKER

Thank you, both, for your help I managed to work out my Java program problems.