Question: //make row public static String makeRow(int num, String str){ String temp = ; for(int i=0 ;i temp = temp + str; } return temp; }

 //make row public static String makeRow(int num, String str){ String temp

//make row

public static String makeRow(int num, String str){

String temp = "";

for(int i=0 ;i

temp = temp + str;

}

return temp;

}

LAB 5 1 Artifact: Learning Outcomes: 3.1, 3.3, 4.1, 4.2 No. of Questions: 15 Total Points: Submission: 10 Submit a java file named LAB5.java 1. Write a program that generates random integers between 3 and 30 (both inclusive). Build a method called printHouse that is passed an odd integer n (the first odd randomiy generated integer above) and a string s (choose between, and ), and that prints a house-like shape using s. The top of the house is a pyramid and the bottom of the house is a square with one less row. The top row of the pyramid prints the string a single time. The second row prints two extra strings and so on. The last row of the pyramid prints n strings. You must reuse the methods you've already written in the class especially makeRow. Sample: Calling printHouse(1, "). from main, prints the following: So basically, ifn is 11, 6 rows of pyramid and 5 rows of squares are printed. You have to find out what if n is 13 or 21 or 23 etc. Your whole solution hinges upon the loop counters. Be wise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!