Difference between revisions of "Beginner Java Exercises"

From WLCS
(New page: === OddOrEven === # Create a class named OddOrEven # Prompt the user for an integer # Print out to the user if the number is odd or even === NumberFun === # Create a class named NumberFun...)
 
Line 7: Line 7:
 
# Create a class named NumberFun
 
# Create a class named NumberFun
 
# Declare three local variables in your main method, name them x, y, and z
 
# Declare three local variables in your main method, name them x, y, and z
# Give x, y, and, z three random numbers (of your choosing)
+
# Prompt the user for x, y, and, z
 
# Your program should output the minimum, the median, the maximum, and the average of the three numbers. Please make your output pretty.
 
# Your program should output the minimum, the median, the maximum, and the average of the three numbers. Please make your output pretty.
  

Revision as of 13:43, 8 May 2009

OddOrEven

  1. Create a class named OddOrEven
  2. Prompt the user for an integer
  3. Print out to the user if the number is odd or even

NumberFun

  1. Create a class named NumberFun
  2. Declare three local variables in your main method, name them x, y, and z
  3. Prompt the user for x, y, and, z
  4. Your program should output the minimum, the median, the maximum, and the average of the three numbers. Please make your output pretty.

AddSquares

  1. Create a Java class named AddEvens.
  2. Create a local integer variable in the main method and assign it a number of your choosing.
  3. The program will output the sum of all the even numbers from 0 through the number you hardcoded. (HINT: use a loop)