# csc 200 hw4 selection and loops part1 solution

CSC 200 Homework #4 Selection and Loops

This homework covers selection and loop statements. You must use these statements in the solutions to these problems. You must also follow the good programming practices discussed in class.

As a general practice for our programming assignments we will assume that the user will enter appropriate data values from the keyboard. If you are expecting the data value to be a whole number then the user will enter a whole number. If you are expecting the user to enter a double value, then the user will enter a double value.

For this homework, you may only use statements that were discussed in class in Chapters 1 through 3 and also Chapter 5 appropriately. We cannot use the information in Chapter 4 that discusses Strings and the math functions. All assignments must be typed. No handwritten work will be accepted.

Homework is not a group exercise. Homework is an individual exercise to make sure that you understand the material that has been covered. You may discuss the homework problems with your classmates in general terms. You may not share the answer or the solution files with your classmates. Your papers must all be your own work. Your instructor should not be able to look at two programs and see that they are too similar. If that happens, then all parties involved will receive a 0 for the assignment.

Part I. Exercises

The answers to the exercises must be typed and printed to turn in as a part of your homework.
You should be able to complete all of these exercises by hand, but you may check them using Eclipse.

Chapter 3 Exercises
1. Chapter 3 Exercises Question 3.30 page 103. In addition to the instructions in the book – explain your value for y after the switch statement is executed.

2. Chapter 3 Exercises Question 3.31 page 103 Complete the problem as described in the book EXCEPT you do not need to draw the flowchart.

Chapter 5 Exercises
1. Chapter 5 Exercises Question 5.3 page 168.
2. Chapter 5 Exercises Question 5.7 page 170. Write a complete main method using good programming practices when you rewrite the while loop as a do/while loop.