Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:09:25+00:00 2026-06-12T18:09:25+00:00

last time i was on here, the only question i needed help with in

  • 0

last time i was on here, the only question i needed help with in my computer science homework involved making a right triangle on 100 lines, here was the code for that:

    public class PrintTriangle {
   public static void main(String[] args) {
      // Print a right triangle made up of *
      // starting at 100 and ending with 1
         int i = 100;
         while (i > 0) {
           for (int j = 0; j < i; j++)
           System.out.print("*");
           System.out.println();
         i--;
         }
   }
}

well now he’s asked us to do the inverse. here’s the actual question:

“Write a program that will draw a right triangle of 100 lines in the
following shape: The first line, print 100 ‘‘, the second line, 99
‘
’… the last line, only one ‘*’. Using for loop for this problem.
Name the program as PrintTriangle.java”

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

i’m sure it’s something simple but everything i’ve tried up to this point has flopped or only created 1 space at a time. any suggestions or help would be greatly appreciated! thank you in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:09:26+00:00Added an answer on June 12, 2026 at 6:09 pm

    OK, first take a look on both the problems. How would you relate them.

    Since the second problem is the reverse of the first, so what you did first in your first code, you need to do that last in this next problem..

    So, your loop should actually work backwards where it ended in the below code.

    int i = 100;
    for (int j = 0; j < i; j++)
               System.out.print("*");
    

    So, think what you need to do to make this loop work backwards.

    Hint: –

    • Incrementing from 0 to 100 is forward
    • Decrementing from 100 to 0 is backwards

      ****  
       ***  
        **
         *  
      

    Also, in your above pattern you see that you need to first print spaces before actually printing your characters So, that too you need to consider.

    So, here you have to actually print two different characters: –

    • Few Spaces, followed by,
    • Few *'s.

    Here’s the pattern: –

    • Let’s the maximum row is max (100 in your case)
    • Row (i) has (i) number of spaces (Row 0 has 0 space, Row 1 has 1 space)
    • Then it has (n - i) number of stars (Row 0 has 100 stars, Row 1 has 99 stars)

    So, you can see that you actually need two loops here.

    Analyze what all I said, and come up with some code. Try it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had much luck last time I submitted a question so here goes: I
Here I am with a similar question as the last time, and for which
After the you guys helped me out so gracefully last time, here is another
First time post here, I hope its a valid question. I've been building a
This is my first time asking a question on here. It has been very
Please help with my assignment. Here is the question: Create a separate test driver
In my last question seen here: Sudoku - Region testing I asked how to
It's been too long since my last question so here is a new one
The last time I did any serious Java coding was back around the turn
it’s been a while since the last time I had to use regex, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.