I am a newbie in programming and I am trying to make a score result program which will suppose to be display the score of the player in display who got the highest score and display if who did not pass
boolean gameOver = true;
int playerOneScore = 200;
int playerTwoScore = 300;
int levelCompleted = 5;
int bonus = 500;
int totalScoreForPlayerOne = playerOneScore + (levelCompleted * bonus);
int totalScoreForPlayerTwo = playerTwoScore + (levelCompleted * bonus);
if (gameOver) {
System.out.println("Game over!");
System.out.println("Your score : ");
System.out.println("Player 1: " + totalScoreForPlayerOne);
System.out.println("Player 2: " + totalScoreForPlayerTwo);
}
else if (totalScoreForPlayerOne >= 5000 && totalScoreForPlayerTwo >= 5000) {
System.out.println("Congratulations you passed!");
}
else if (totalScoreForPlayerOne > totalScoreForPlayerTwo) {
System.out.println("Congratulation you got the highest score! " + totalScoreForPlayerOne);
}
else if (totalScoreForPlayerTwo > totalScoreForPlayerOne) {
System.out.println("Congratulation you got the highest score! " + totalScoreForPlayerTwo);
}
else{
System.out.println("You did not pass");
}
}
}
Game over!
Your score :
Player 1: 2700
Player 2: 2800
Desired result would include:
Congratulation you got the highest score! 2800
This is not printed. Why not? How do I fix?
Aucun commentaire:
Enregistrer un commentaire