hw5 - CS112: Homework #5 1. Create a new project loops-hw5....

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS112: Homework #5 1. Create a new project loops-hw5 . 2. Create a new class, called FunWithLoops . Delete everything but the outer wrapper. 3. Random Praise. In the FunWithLoops class, create the following method. There are no instance variables for this class. We are just going to write and test methods. Write a void method, randomPraise(String name, int n) that will print to the Terminal Window n times a nice sentence about name. The nice sentence will be picked randomly from a set of say 3 sentences. Here is how you pick the random phrase. Generate a random number from 1 to 3, save it in a local variable. (See how this was done in the Die example.) Make another local String variable. Use a big if statement so that depending on what the random number was, you set this String variable to a certain phrase. Then print that phrase to the screen using a loop. 4. Reminder: In Java, multiplication is the asterisk * and division is /. 5.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/08/2008 for the course CSCI 112 taught by Professor Yuen during the Fall '07 term at Lake Forest.

Ask a homework question - tutors are online