Skip to content

Latest commit

 

History

History
70 lines (44 loc) · 2.77 KB

Conditionals_LAB.md

File metadata and controls

70 lines (44 loc) · 2.77 KB

Exercises: if/else if/else statements

What number's bigger?

Write an if statement that tests two number (numOne and numTwo), and prints the biggest number

Driving Age

  • Store the user age
  • If age is less than 18, print "Sorry, you can't drive yet"
  • If the age is equal to or over 18, print "Drive away!"
  • Bonus: If the user can't drive yet, tell them how many years they will have to wait. E.g. "Sorry, you have 4 years to wait until you can drive"

The World Translator

Write an if statement that writes Hello World in different languages (i.e. if the language is English, print "Hello World", if the language is Arabic write something "مرحبا بالعالم", if the language is French write something romantic)

Suburbs

  • Create a program that stores a user's suburb.
  • Depending on the answer, print an appropriate response of your choosing (e.g. maybe what team they might support, what activities the user might engage in etc.)

The Grade Assigner

Write an if statement that gives users a score (A, B, C, D, or F) based on the test results

Air Conditioning

  • Store the current temperature, whether the A/C is functional, and what the desired temperature is.
    • If the airconditioner is functional and the current temperature is above the the desired temperature... print "Turn on the A/C Please"
    • If the airconditioner is non-functional and the current temperature is above the the desired temperature... print "Fix the A/C now! It's hot!"
    • If the airconditioner is non-functional and the current temperature is below the the desired temperature... print "Fix the A/C whenever you have the chance... It's cool..."

Golf

Write an if statement that gives a user the nickname of their score, based on par.

Score Nickname
1 "Hole in one"
<= par - 2 "Eagle"
par - 1 "Birdie
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"
>= par + 3 "Not sure"

Serge Says

Store a user message

Print 'Sure.' if you ask a question (e.g. the message ends in ?).

Print 'Woah, chill out!' if you yell (e.g. your message is in all capitals).

Print 'Fine. Be that way!' if you don't say anything (e.g. your message is empty).

Print 'Whatever.' to anything else.

Bonus: If the message is all spaces, also print "Fine. Be that way!"

The Pluralizer

Write an if statement that works with a noun and a number. Make the noun plural if necessary!! Make this as accurate as possible (e.g. use the rules described here)

The Rest

  • Implement a Rock, Paper, Scissors single game
  • Implement a Rock, Paper, Scissors best of three game
  • Anything else you can think of!