Question

JAVA question creating the following (it doesn't have to be exact same number of asterisks) please...

JAVA question creating the following (it doesn't have to be exact same number of asterisks)

please use loop , whether that is 1 loop or 2 loop, but simple , understandable ones would be appreciated!

Also please leave comments next to them so I can understand! Thanks!

*
**
***
****
*****
****
***
**
*

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

Pyramid.java:

public class Pyramid {
    public static void main(String args[]) {
        int i, j;
        for (i = 1; i <= 5; ++i) {
            for (j = 1; j <= i; ++j) {
                System.out.print("*");
            }
            System.out.println();
        }
        /*print half pyramid with 5 rows */

        for (i = 4; i >= 1; --i) {
            for (j = 1; j <= i; ++j) {
                System.out.print("*");
            }
            System.out.println();
        }
        /*prints second half of pyramid with 4 rows */
    }
}

Output:

Add a comment
Know the answer?
Add Answer to:
JAVA question creating the following (it doesn't have to be exact same number of asterisks) please...
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
  • JAVA HELP! Question: Write a Java console application that investigates how well Java handles large integers....

    JAVA HELP! Question: Write a Java console application that investigates how well Java handles large integers. Write two loops that iterate from 0 through 35. Before each loop, set an integer variable (IV) to 1. Within each loop, print the loop count and the value of IV formatted in two columns. Within the first loop, multiply IV by 2. Within the second loop, multiply IV by the appropriate StrictMath method. The second loop will not complete since there will eventually...

  • I need help in creating a testcode for this pseudocode in Java. For following questions, please...

    I need help in creating a testcode for this pseudocode in Java. For following questions, please provided your solutions for each of the questions ina separate Word document. 1. Write pseudocode for the following problem: (10 points) You are in charge of the school's IT department and several classes are asking to by iPads for use in their classes. Based on the number ofiPads each class requested, determine the total costs for each classroom. The only information given is that...

  • This exact question has been asked again but it doesn't follow the same format and I...

    This exact question has been asked again but it doesn't follow the same format and I can't tell what they are trying to say.   home / study / business / accounting / accounting questions and answers / wilma company must decide whether to make or buy some of its components. the costs of producing ... Question: Wilma Company must decide whether to make or buy some of its components. The costs of producing 6... Wilma Company must decide whether to...

  • Hi I would like to make a simple query rewriting program with Java. When I ask...

    Hi I would like to make a simple query rewriting program with Java. When I ask where question so for example, where (is the Louvre Museum located?) The answer would be the Louvre Museum is located in _____ like this Just change and re-phrase the sentence or more phrase changes if you think it is easy How can I make this simple code when users ask any where questions in prompt Please help me it would be great help to...

  • question of java , very simple one written under with comment, just reply next or below...

    question of java , very simple one written under with comment, just reply next or below it, thanks public static void main(String[] args) {        // TODO Auto-generated method stub        int i, j;        final int ARRAY_LENGTH = 5;        int[] myArray = new int[ARRAY_LENGTH];               for(i=0; i< myArray.length; i++)        {            myArray[0] += 2;          }               for(j = 0; j       ...

  • Those are  JAVA Programs. Please write them in recursions , it requires the methods have to be...

    Those are  JAVA Programs. Please write them in recursions , it requires the methods have to be recursive(I understood how to write them by using for loop). Please don't use any syntax beyond chapter of Recursion. I only covered the materials to recursions and the materials before recursion chapter. Appreciated! #1) Write a recursive method writesquares that accepts an integer n and prints the first n squares with the odd squares in decending order, followed by the even squares in acending...

  • PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from...

    PLEASE HELP!!!I need help with the following JAVA PROGRAMS. Please ready carefully. So this comes from tony gaddis starting out with java book. I have included the screenshot of the problems for reference. I need HELP implementing these two problems TOGETHER. There should be TWO class files. One which has TWO methods (one to implement problem 8, and one to implement problem 9). The second class should consist of the MAIN program with the MAIN method which calls those methods....

  • I need help creating a Mean Filter for Matlab 3 by 3. ( I need the...

    I need help creating a Mean Filter for Matlab 3 by 3. ( I need the Actual Matlab WORking code) It's dude tomorrow, final project worth 40% of my grade. It can not use Matlab Function, must be user define fuction. So far what I have is, I am not sure how to start this, I was told it requires 2 for loops A= imread('lena_256.tif'); % Reads the image in matrix M = ones(3,3)/9; % Creates a matrix of 3...

  • Java programming. Please, could you add the comment so I can follow and understand. Thanks Create...

    Java programming. Please, could you add the comment so I can follow and understand. Thanks Create a program with JavaFX that displays a bouncing graphics (an image of a ball or the head of Darth Vader or anything else). The object should bounce around in the window. There should also be a button in the win- dow that releases another object (unlimited number should be possible to have in the window, but only one new object should be released for...

  • java code please 14. Next we'll complete the setValues() method. Instead of giving you exact code...

    java code please 14. Next we'll complete the setValues() method. Instead of giving you exact code I'll tell you what to do. Use other code as a guide.  Start with a for loop with a start of int i = 0  Set the ending point of when i is less than the length of the arr array.  Set the incrementation to increase i by 1 using the unary operator ++.  Within the loop set the arr...

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