PRACTICE
CONDITIONAL EXERCISES



Exercises

  1. Write a program to simulate a magic-8 ball. Have your program:
  1. Write a program which asks the user for 3 numbers, and prints out the largest of the 3.
  2. Write a program that asks the user for a month, and prints out the number of days in that month.
  3. Write a program that asks for the user’s letter grade, and prints out a report card comment based on their achievement.
  4. Write a program that asks the user for 2 decimal numbers, and prints out “True” if the two numbers are the same up to 3 decimal places.
  5. Write a program that asks a user for an integer and determines if that number is even, odd, zero, positive, or negative. If the number is positive/negative, it can also be even or odd!
  6. Write a program that generates a random number between 50-150. Have the user input an int and tell the user if their number was higher than, lower than, or equal to the random number.

  1. Given 3 int values inputted by the user, a, b, and c, calculate and print their sum. However, if one of the values is the same as another of the values, it does not count towards the sum. For example…

  1. Given 3 int values inputted by the user, a, b, and c, calculate and print their sum. However, if any of the values is a “teen” -- in the range 13..19 inclusive -- then that value counts as 0. Except 15 and 16 do not count as teens. For example…
  1. Someone has spotted a Discreet Concerning, Troubling  Item soaring through the sky! Not only that, but they’ve spotted some aliens on board. We want to determine what kind of aliens are piloting the DCTI, based on their appearance. We are only aware of three alien species:

Write a program that asks the user for the number of eyes and antennae they saw. The program should print all possibilities for what alien it could be.