HW 4.7, 4.8, 4.9

October 11, 2007 at 4:10 pm (Uncategorized)

4.7
1.
a) The reader asks the user for a positive integer “i”. In this case to find i’s properdivisors, we must try the values of d between 1 and i/1.
b)the reader trying to guess the number of user between 1 to 10.
2.
a) while (x<20)
if(x%2=0)
y=x^2
y=x^3
(x++)
system.out.print(x+”"+y)

b).

4.8
1. Program filters a set of integers by removing all of the zeroes and retaining the other values, The inputs are in a text file named numers.txt, whereas the outputs go to a file named newnumbers.txt.
2.

Permalink Leave a Comment

4.3

October 1, 2007 at 3:14 pm (Uncategorized)

1.
while is a control statement which means while the ( ) hold true, repeat the next statement that comes

2.
if else statement makes “if () is true, then do stuff 1, else makes do stuff 2)
a. there are checkers;
if (checker piece is red) {
put it on the red square;
}
else {
put it on the black square;
}

b. shoes are muddy;
if (your shoes are muddy) {
take them off;
leave them outside the door;
}

c. there are marbles on the floor;
while (marbles on the floor) {
pick them up;
pu them into a bag;
}

3.a. if x is larger than y, x equals temperature, equals y, and y equals temperature too.
if x is less than or equal to y, then y equals temperature, equals x, and x equals temperature.

b. when sum equals one, and count equals 1, put an integer to the total.
But when count is less than or equal to total, make x into an integer. Sum equals sum added by absolut value of x. total is greater than 0, sum divided by total.

Permalink Leave a Comment