Programming and Computer Science in Java:
Quiz #3:   Lab Programs 1-10
    David Kosbie, 2002-2003
See Course Home Page

Quiz Date:  Wed, Feb 26, 2003

This quiz covers Programs 1-10 in Lab #1, but does not cover any of the Additional Exercises in that lab.

Important note:  Quiz difficulty levels will increase with each of the first few quizzes.  That is, this quiz is quite a bit less difficult than future quizzes in this class.

Question 1:  Write a Java program which uses a while statement to compute and print out the sum of the integers from 123 to 789.  That is, 123 + 124 + ... + 788 + 789.

Question 2:  Write a Java program which reads in integers, stopping only when the same integer is entered in twice in a row. Print out the total number of integers read.

Question 3:  Give the value that each of the following expressions evaluates to (you should assume that all values are integers, and all math is integer math).
3a)  2 * 3
3b)  2 * 3 + 4 
3c)  2 + 3 * 4
3d)  9 / 3
3e)  10 / 3
3f)   11 % 3
3g)  Math.abs(10) + Math.abs(-10)
3h)  Math.abs(10 + -10)
3i)  Math.max(1,2)
3j)   Math.min(1,2)
3k)   Math.max(Math.min(1,2),Math.min(3,4))


See Course Home Page