Java

TOPIC 32 – BOOLEAN FUNCTIONS

 

LESSON WORK

 


QUESTION 0 (GROUP WORK)

We will create a guess the number game making use of functions to lower complexity and maintain clear organization.

QUESTION 1

 

A)   Create the following functions:

 

     public static boolean isLegalMark(int m)

 

            Returns true if the mark is between 0 and 100.  Returns false otherwise.

 

     public static String letterMark(int m)

 

            Returns the letter representation of the mark m.  For example, if m is between 80 and             100, the function returns “A”.

 

B)   Test the two functions above inside a main.  Get a mark from the user, check its legality and output its letter value to the screen.

 

QUESTION 2

 

A)   Create the function:

 

Public static boolean playAgain()

 

This function asks the user whether they want to play again.  If the user entered “yes”, then the function returns true.  Otherwise, it returns false.

 

B)   Test this function simply by outputting its result.