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 6742745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:52:48+00:00 2026-05-26T11:52:48+00:00

Hi i am doing my coursework and i have been given the task is

  • 0

Hi i am doing my coursework and i have been given the task is to make an algorithm for a square that’s 5×5 using “*” but has to be filled in with “.” so like this:

*****
*...*
*...*
*...*
*****

I have used this code I know its probably very messy because im an absolute beginner to this stuff. I cant seem to get the “.” in i currently have:

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

here is my code:

public static void main( String args[] )
{
    System.out.print ("#size of square");
    int stars=BIO.getInt();
    int j=1;
    while(j <= stars)
    {
        int starsNumber=1;
        while (starsNumber<= stars)
        {
            int i = 1;                        // Display trunk
            starsNumber=starsNumber+1;
            System.out.print('*');
        }
        System.out.println();

        j= j +1;
    }
}

p.s sorry for been so bad at coding 😀 and any help would be much appreciated thanks Gareth

  • 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-05-26T11:52:48+00:00Added an answer on May 26, 2026 at 11:52 am

    Have you gotten the program to print an 5×5 square full of asterisks working?

    I’d strongly recommend getting that working first. After that, you just need a minor modification to print the dots in between.

    For that, instead of always printing an asterisk, you’ll need a conditional.

    Pseudocode:

    if(I'm currently on the edge)
      Print an asterisk
    else
      Print a dot
    

    I’ll leave it to you to figure out how to translate this into real code. Good luck!

    Edit, hints on how to determine if you’re currently on the edge:

    1. You are keeping track of the current row and current column (in order
      to print a square exactly 5×5 characters).
    2. The edge consists of the first and last row, and the first and last column.
    3. Given hint 1 and hint 2, can you now determine when you are on the edge and when you’re not? You’ll need to do variable comparison, so read your textbook if you’re not familiar with how to compare variables.

    Hope that helps. There’s really not much more I can say without giving away the exact answer.

    Finally, think about your solution before coding it. Immediately jumping into coding can be a roadblock, especially when you’re a beginner and not too familiar with the language so you get bogged down in the language syntax. Mentally put together the flow of your program, draw pictures, and maybe write pseudocode before you write the actual code. I find that doing this helps me write code easier and reduces the number of bugs that come up.

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

Sidebar

Related Questions

Doing a search using django-sphinx gives me results._sphinx that says there were 68 results,
I'm doing some coursework for uni, I really should know this but I am
Doing a small project I have received some Java code that I should rewrite
Doing some code reviews lately I came across a number of classes that have
Doing a little search i realized that to make an equalizer. I need to
Doing some profiling (mem & speed) I've been stomped by the fact that win7
Im doing something like this to get a list of all users that have
doing some jQuery animation for a high profile client that has to be finished
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing some jquery animation. I have certain divs set up with an attribute of

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.