CSCI 1301 – Lab 17

Clément Aubert

October 15, 2018

Basic Conditional Statements

Read all the instructions in this part before starting to type code. Create a new project, and write portions of code that perform the following:

  1. Ask the user for an integer, and display on the screen “You were born after me” if the number is strictly greater than your year of birth.
  2. Ask the user for an integer, and display on the screen “Between  − 1 and 1” if the number is greater than or equal to  − 1 and less than or equal to 1.
  3. Ask the user for an integer, and display on the screen “Not between  − 1 and 1” if the number is greater than 1 or less than  − 1.
  4. Ask the user for an integer, and display on the screen “Odd” or “Even”, depending if the number is odd or even.
  5. Ask the user for an integer, and display on the screen “Negative” if the integer is negative, “Positive” if the integer in positive, and nothing if the integer is 0.
  6. Ask the user for an integer, and display on the screen “positive and odd” if the number is positive and odd, “positive and even” if the number is positive and even, “negative and odd” if the number is negative and odd, “negative and even” if the number is negative and even, and “You picked 0” if the number is 0.

For each of those questions, write on paper whenever you should use if, if-else, if-else-if or nested conditional structures, and what the condition(s) should be. Once you feel confident, write the code in VS, and then test it intensively: enter all kind of values (positive and odd, negative and even, 0, and remember that 0 is even, etc.) and make sure that what is displayed on the screened is always correct.

Problem Solving

You are asked to write a simple program that compute the total price for a group of people to enter a park.

Your program should:

Some tips: