Labs

  1. Write a program that reads an int number from the user. Use an expression to determine if the number is even (use the modulus operator, %.) Store the result of the expression in a boolean variable. Write an if statement that uses the variable to determine whether to print Odd. or Even..

(Solution: solutions/OddOrEven.java)

  1. Write a program that prompts the user five times to enter an integer number. The first time, store the number in an int variable, and print it out. The remaining four times, use *= to multiply the variable by the user's input and print it again.

(Solution: solutions/Multiply.java)

  1. Write a program that reads a number from the user and prints out whether the number is positive, negative, or zero. Use no if statements.

(Solution: solutions/PosNegZero.java)


Prev -- Up