# lab 4 - Name Lab Section(circle one M T W Th CS 240...

This preview shows pages 1–2. Sign up to view the full content.

Name________________________________ Lab Section (circle one): M T W Th CS 240 Laboratory Exercise 4 Due date/time: Friday, May 1, 12:00 noon. You may turn the printout in to me, to your lab assistant or bring it to the dept. office (303 Russ). No late work accepted! What to turn in: Turn in this lab handout, the printout from Exercise 2, and printouts for each problem in Exercise 3. Be sure to include your name as a comment on each printout. Exercise 1: Each of the following three code fragments uses a loop to perform a task. However, each code fragment contains at least one error. Find and fix the errors. You may simply write the corrections on this paper, you do not need to enter complete programs for this exercise . Problem 1: //this code sums the numbers from 1 to 100 int count = 1, total; while (count <= 100) total += count; System.out.println(“The sum of the numbers 1 – 100 is ” + total); Problem 2: //this code sums two numbers entered by the user and then repeats as long as //the user wishes to continue summing pairs of numbers int num1, num2; String input; char again; Scanner keyboard = new Scanner(System.in); while (again == ‘Y’ || again == ‘y’);

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

lab 4 - Name Lab Section(circle one M T W Th CS 240...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online