Skip to content

Instantly share code, notes, and snippets.

@johnmcc
Last active March 14, 2017 16:19
Show Gist options
  • Save johnmcc/183d9554052a2afe7c47e040017063cd to your computer and use it in GitHub Desktop.
Save johnmcc/183d9554052a2afe7c47e040017063cd to your computer and use it in GitHub Desktop.

Java problems.

Choose one:

Task 1

  • Write a guessing game where the user has to guess a secret number.
  • After every guess the program tells the user whether their number was too large or too small.
  • At the end the number of tries needed should be printed.

Task 2

  • Write a program in Java to check if a number is even or odd in Java?
  • e.g user inputs 2 console outputs 'true', input 3 : output false, etc)

(Hint - A number is called even if it is completely divisible by two and odd if it’s not completely divisible by two. For example number 4 is even number because when you do 4/2 , remainder is 0. On the other hand 5 is odd number because 5/2 will result in remainder as 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment