Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

//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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

5. Develop the succession planning review.

Answered: 1 week ago