Question

In Parts This Skill Builder will require you to write several functions in which loops will be the focus. In addition, some othat returns a string consisting of asterisks in a right-right triangle pattern with a height, height. When the method is invIf printed, System.out.println (SkillBuilder6.circle (5)) the result is, Invoking the method with a different argument, SkillLoad default template... SkillBuilder6.java k w 3 SkillBuilder6 is a class for completing the Skill 4 Builder 6 assignment in

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class SkillBuilder6 {

public static String leftRightTriangle(int height)

{

String str = "";

int i, j;

// outer loop to handle number of rows

// n in this case

for(i=0; i<height; i++)

{

// inner loop to handle number of columns

// values changing acc. to outer loop

for(j=0; j<=i; j++)

{

str += "* ";

}

str += "\n";

}

return str;

}

public static String rightRightTriangle(int height)

{

String str = "";

int i, j;

// outer loop to handle number of rows

// n in this case

for(i=0; i<height; i++)

{

// inner loop to handle number spaces

// values changing acc. to requirement

for(j=2*(height-i); j>=0; j--)

{

str += " ";

}

// inner loop to handle number of columns

// values changing acc. to outer loop

for(j=0; j<=i; j++)

{

str += "* ";

}

// ending line after each row

str += "\n";

}

return str;

}

}

NOTE: As per HOMEWORKLIB POLICY, I am allowed to answer only 2 coding questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
In Parts This Skill Builder will require you to write several functions in which loops will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am trying to write a Geometry.java program but Dr.Java is giving me errors and I...

    I am trying to write a Geometry.java program but Dr.Java is giving me errors and I dont know what I am doing wrong. import java.util.Scanner; /** This program demonstrates static methods */ public class Geometry { public static void main(String[] args) { int choice; // The user's choice double value = 0; // The method's return value char letter; // The user's Y or N decision double radius; // The radius of the circle double length; // The length of...

  • Write the example code to describe overloading and submit here. You need to put comments for...

    Write the example code to describe overloading and submit here. You need to put comments for your code. You need to add at least one more overloaded method to the example code. public class OverloadingExample { public static void main(String[] args) { OverloadingExample t = new OverloadingExample(); t.methodX(5,9,2.2); t.methodX(5,9,"Hi"); t.methodX(5,9,2); t.methodX(5,9); } public void methodX(int a){ System.out.println("This is the method X with 1 parameters!"); } public void methodX(int a,int b){ System.out.println("This is the method X with 2 parameters!"); } public...

  • 10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use...

    10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use the main method to test your code. Submit the file AppendRec.java. There is no need to delete the main method, the autograder will only grade appendNTimes. The method appendNTimes is recursive and takes two arguments, a string and an integer. It returns the original string appended to the original string n times. The method signature is as follows public static String appendNTimes ( String...

  • JAVA Code Requried Copy the file java included below. This program will compile, but, when you...

    JAVA Code Requried Copy the file java included below. This program will compile, but, when you run it, it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create this. Below the main method, but in the Geometry class, create a static method called printMenu that has no parameter list and does not return a value. It will...

  • Project Objectives: To develop ability to write void and value returning methods and to call them...

    Project Objectives: To develop ability to write void and value returning methods and to call them -- Introduction: Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing the smaller tasks (calling the methods) in the correct order. This also allows for efficiencies, since the method can...

  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • What will the following program display? public class checkpoint { public static void main(String urgs[]) {...

    What will the following program display? public class checkpoint { public static void main(String urgs[]) { int n = 1776; doubled = 110.0901; System .out.println(n + “\t” + d); myMethod(n, d); System.out.println(n + “\t” + d); } public static void myMethod(int i, double x) { System.out.printing + “\t” + x); i = 1250; x= 199.99; System.out.println(i + “\t" + x); } } Write the following two methods: i. compute Diameter; This method accepts the radius (r) of a circle, and...

  • Write a java class definition for a circle object. The object should be capable of setting...

    Write a java class definition for a circle object. The object should be capable of setting radius, and computing its area and circumference. Use this to create two Circle objects with radius 10 and 40.5, respectively. Print their areas and circumference. Here is the Java class file (Circle.java). Compile it. public class Circle{ //Instance Variables private double PI = 3.1459; private double radius; //Methods public Circle ( ) { }    //get method (Accessor Methods ) public double getRadius (...

  • Create a Java application that allows user to build a Priority Queue of Circle Elements (i.e.,...

    Create a Java application that allows user to build a Priority Queue of Circle Elements (i.e., priority based on the radius of the circle). The application must be menu controlled similar to Project 4 and provide the following. Allow insertion of a "Circle" object/structure in the Priority Queue data structures. Allow display of all elements from Priority Queue data structure by Invoking a method/function "DisplayPriorityQueue" (uses "DeQueue" method). Allow for deletion of the Queue This is what I have so...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT