Hi danpost
It has been quite a while since I have last come here. I am doing my final game project. it is a multiplication multiple choice game.
It is the first part of the game where you have to ask the user to enter their name and age. but it have a criteria for the age. the user has to be between the age 8 - 13.
if the user enter the 1 -7 the game supposed to end and it should hit the if else statement which mean that they are to young to play the game. i have input another if else statement where if the user enter any age above 13 years it should also end the game and should have read the else if statement stating that the user is too old for the game and if the user enter the correct age it should enter the else statement to continue the game but the things am not getting it to enter the second else if statement when the user the incorrect age which is above 13 year.
can you tell me why it is only hitting the first else if statement and not the second one. here is the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | System.out.println( "Hi what is your name " ); String playername = reader.next(); System.out.println( "oh, what a lovely name you have" ); System.out.println( "Hi what is your age" ); player1age = reader.nextInt(); if (player1age < 8 || player1age > 13 ) { System.out.println(playername+ " you are to young to play this game" ); System.exit( 0 ); } else if (player1age > 8 || player1age > 13 ) { System.out.println(playername+ " you are too old to play this game " ); System.exit( 0 ); } else { System.out.println(playername+ " come let us have some fun playing this game" ); } |