Discussion Questions
CS 312


1. Write a Java program that displays the following output. Use static methods and for loops to simplify the solution and eliminate redundancy.

*****
*****

-----
-----
*****
*****
-----
-----
*****
*****

2. Write a for loop that prints the following output:

-3
-2
-1
0
1
2
3


3. Write down the value of the following Java expressions:

a. 45/4
b. "he" + 1 + 2
c. 400%7%2
d.  815 % 100 / 3 + 2.7


4. Re-write each assignment statement using an assignment operator (e.g., +=, *=). Assume the following declarations and initializations have been made.
int x = 5;
double y = 2.1;
int z = 3;
String s = "hello";

a. x = x + 10;
b. x = x + y;
c. y = 10*y;
d. z = z * (x+y);
e. s = s + "there";