Main Loop

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

Only one player will win. Each round always adds one point to just one player, so just one player will be the first to reach ten points

Main Loop

Here is the logic that implements the main loop:

  // Declare and Initialize
  final int endScore=10;

  int playerScore=0, compScore=0;
  
  // Play Rounds until one player reaches ending score
  while ( playerScore<endScore && compScore<endScore )
  {
    . . . .
  }
    

The body of the loop corresponds to one round of the game.

QUESTION 20:

(Review: ) What does final int endScore=10; do?