A Run of the Program

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

Fill the blank so that weight is tested in two ways:

  • weight must be equal or greater than 136
  • weight must be less than or equal to 147

Answer:

    // check that the weight is within range
    if ( weight >= 136 && weight <= 147 )
      System.out.println("In range!" );
    else
      System.out.println("Out of range." );

A Run of the Program

The boxer must weigh enough (weight >= 136), and must also not weigh too much (weight <= 147). The results of the two tests are combined with the and-operator, &&. Here is a JavaScript version of the program:


How heavy is the boxer? 

  


QUESTION 10:

Run the program for a weight of 140.