Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
Else If Practice

Else If Practice Exercise


Video Summary: https://youtu.be/LLaMhgTmXEY


Consider the solution to a previous exercise that generated two dice rolls:


In this program, there are three possible outcomes:

  1. Player one rolls a higher value than player two
  2. The players roll the same value
  3. Player two rolls a higher value than player one

Add control so that the program outputs which player won, or if there was a draw. When you are done, your output might look like this:

Player one rolled 1
Player two rolled 3
Player two wins!

Solution