



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




replicate
-^ Add^ another function
replicate^ that prints the character
โ*โ^ a
specified number of times
on one line. The method should look like this:^ public^ static
void^ replicate(int
times)
times^ is the number of times
โ*โ^ is printed^
on one line.
-^ Test the method by making a call to
replicate^ method in the main program like this:
replicate(25) What shows up on the screen?
replicate method in a loop to print a 4-row rectanglewith 25 โ*โ symbols in each row:^ *************************^ *************************^ *************************^ *************************
-^ Add^ a third function^ replicate(char symbol, int times)^ that prints a character
symbol^ a specified number^ times
times.
replicate
with parameter-values
โ#โ^ and^5
respectively:^ replicate(โ#โ, 5) ; What prints?
m ร n โ
rectangle of a specified symbol (see dialogbelow): Number^ of
rows:^2 Number^ of
columns:
Character
to^ print:
x xxxxxxx xxxxxxx
*โ characters? ******************** ******************** ********************
-^ How about printing a 3x4 โ rectangle of โ
#โ characters?