Question: HELP WITH JUNIT JU15V.java /** * Name: Firstname LastName * * Nested Loops * * @version 2.0 - added more examples to buildStairs and buildNumberMountain
HELP WITH JUNIT
JU15V.java
/**
* Name: Firstname LastName
*
* Nested Loops
*
* @version 2.0 - added more examples to buildStairs and buildNumberMountain
*/
public class JU15V
{
/**
* Given a height and width, return a box of asterisks with those dimensions.
*
*
* buildGridOfStars(4,2) -> "**
* **
* **
* **"
*
* buildGridOfStars(3,5) -> "*****
* *****
* *****"
*
*/
public static String buildGridOfStars(int height, int width)
{
// You must solve using a FOR loop(s).
// No credit for using a while loop.
String answer = "";
// put code here:
// Did you know there are Java methods and statements
// that are forbidden to use? For example, you
// can't use charAt. Use substring instead.
// Click the link at the bottom of the lesson
// to pull up a list of all of the forbidden Java stuff.
return answer;
}
/**
* Generates and returns a times table given a height and width. It's ugly
* because the spacing will look weird, but this makes it easier for you to
* solve the problem. Each number will have a single space after it.
*/
public static String uglyTimesTable(int height, int width)
{
// You must solve using a FOR loop(s).
// No credit for using a while loop.
String answer = "";
// put code here:
return answer;
}
/**
* Given a width less than 21, this method will return a string of width stars
* with dots in front of them. The whole length of the returned string is 20.
*
*
* buildRightJustified(3) -> ".................***"
* buildRightJustified(5) -> "...............*****"
*
*/
public static String buildRightJustified(int width)
{
// You must solve using a FOR loop(s).
// No credit for using a while loop.
String answer = "";
// put code here:
return answer;
}
/**
* Given a height, build a pyramid of symbols that is right justified. For
* example:
*
*
* buildStairs(3, "$") ->
* " $"
* " $$"
* "$$$"
*
* buildStairs(6, "@") ->
* " @"
* " @@"
* " @@@"
* " @@@@"
* " @@@@@"
* "@@@@@@"
*
*/
public static String buildStairs(int height, String symbol)
{
// You must solve using a FOR loop(s).
// No credit for using a while loop.
String answer = "";
// Hey, you! Post a private topic to your teacher and get
// really helpful hints on how to do this problem.
return answer;
}
/**
* Creates a set of stairs built with increasing numbers. You send it the
* number of rows it needs to build. Look at the examples:
*
*
* buildNumberMountain(3) -> "1 "
* "2 3"
* "4 5 6"
*
* buildNumberMountain(7) -> "1 "
* "2 3"
* "4 5 6"
* "7 8 9 10"
* "11 12 13 14 15"
* "16 17 18 19 20 21"
* "22 23 24 25 26 27 28"
*
* buildNumberMountain(5) -> "1 "
* "2 3"
* "4 5 6"
* "7 8 9 10"
* "11 12 13 14 15"
*
*/
public static String buildNumberMountain(int rows)
{
// You must solve using a FOR loop(s).
// No credit for using a while loop.
String answer = "";
// Did you know that your teacher is really
// happy to answer a question in your private topic?
// Your teacher doesn't want you to struggle for hours
// on this problem. Why not post a private topic today?
return answer;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
