Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 1.47 KB

conditionals.md

File metadata and controls

19 lines (13 loc) · 1.47 KB

#Conditionals

###Resources If-then/If-then-else

Complex conditionals/combining boolean expressions

###Exercises

  1. Write a method isOdd that takes in an int n. Returns a true if n is odd, and false otherwise.
  2. Write a method isMultipleOfThree that takes in an int n. Returns true if n is a multiple of three, and false otherwise.
  3. Write a method isOddAndIsMultipleOfThree that takes in an int n. Returns true if n is both odd and a multiple of three, and false otherwise.
  4. Write a method isOddAndIsMultipleOfThree2 - if you used isOdd and isMultipleofThree in your last solution, don't use it this time. If you did not, write this method building on your last methods.
  5. Write a method fizzMultipleofThree that takes in an int n and prints "Fizz" if n is a multiple of three, and prints n otherwise.

Look at Person.java from the assessment.

  1. Write a method that takes in a Person and returns true if the person is from London, and false otherwise.
  2. Write a method that takes in a Person and prints the name if the person has a name longer than 5 characters, and otherwise prints "Name is too short."