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

  • Home
  • SEARCH
  • 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 8713691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:24:07+00:00 2026-06-13T05:24:07+00:00

How would I use three methods to produce an output like this? Please enter

  • 0

How would I use three methods to produce an output like this?

Please enter the fill character: "z"
Please enter the size of the box (0 to 80): "3"
+---+
|zzz|
|zzz|
|zzz|
+---+

My code is able to produce a box, however I am having issues understanding the use of other methods to create the border around it.

 import java.util.Scanner;
public class SolidBoxes
{
    public static void main(String[] args)
    {
        int start = 0;
        Scanner scan = new Scanner(System.in);

        System.out.print("Please enter the fill character: ");
        String character = scan.next();

        System.out.print("Please enter the size of the box (0 to 80): ");
        int size = scan.nextInt();

        if ( size > 80 || size < 0)
        {
            System.out.println("Please enter the size of the box (0 to 80): ");
            size = scan.nextInt();
        }

        for ( int i = 0; i < size; i++)
        {

            System.out.println();

            for ( int j = 0; j < size; j++)
            {   
            System.out.print(character);
            }

        }   
    }
}

This gives me the output:

Please enter the fill character: z
Please enter the size of the box (0 to 80): 3

zzz
zzz
zzz

How is it possible to add two other methods for the “+—+” and another method “|”?

  • 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-13T05:24:08+00:00Added an answer on June 13, 2026 at 5:24 am

    Methods provide a way to compartmentalize portions of your code into various tasks you want to perform. Typically a method will perform all actions required for a specific task. Methods are called from other code when that calling code wants to perform the specific task that you implemented in the method. For example if you want to draw a shape in your main you might have a method that looks something like this:

        public void drawShape(...){
           ...
           //Put specific code to draw the shape here
           ...
        }
    

    Then inside your main whenever you want to draw that shape you would just call the method like this:

         drawShape(...);
    

    In the method above the public part is the access modifier which tells us that this method is publicly available to any code that can “see” it. The void part is the return type, in this case it is not returning anything. The drawShape is the method name.

    In your case it looks like you need to provide three separate methods. To start with you should define a method for outputting your first line and then getting the fill character and returning that to the main. Then provide a second method to output the second line and return the size of the box to main. Finally provide a third method to output the box based on the first two inputs that you received. When you are finished writing those three methods then call them in the right order from main to run the complete program.

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

Sidebar

Related Questions

I would like to use this script https://github.com/jeromeetienne/jquery-qrcode (or is there even a better
There's a Java library that I would like to use in my project. My
I would like to use a very wide image on my website. There is
Is there a way to integrate CodeIgniter with phpBB3? I would like to use
I use Wicket framework and I would like to know if there is a
I use ancestry to make a tree of goals. I would like to send
What I would like to do there is declaring class variables, but actually use
I would like to generate javadoc but excluding deprecated methods from it. I know
I'm trying to use the Autocomplete plugin to produce a search box similar to
I would use a multi dimensional gaussian modell for regression. Rasmussen has a book

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.