{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

InClassExercise11 - CS112 In-class Exercise 11 basic loops...

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

View Full Document Right Arrow Icon
CS112: In-class Exercise 11 basic loops 1. Create a new project loops-11 . 2. Create a new class, called TestingLoops . Delete everything but the outer wrapper. 3. In this TestingLoops class, create the following methods. There are no instance variables for this class. We are just going to write and test methods. Write a void method, praise(String name, int n) that will print to the Terminal Window n times a nice sentence about name. You decide on the sentence. Create a TestingLoops object, and invoke the praise method with various inputs. For example, invoking praise(“Odie”, 7) might print the sentence “Odie is great.” 7 times. And invoking praise(“Garfield”, 20) might print the sentence “Garfield is adorable.” 20 times. Write a int method, sumUpSquares(int n) that computes and returns an integer that is the sum of the first n squares. (1 + 4 + 9 + …). This method should be a very simple modification of the sumUp method that we did in class.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online