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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:39:20+00:00 2026-06-12T11:39:20+00:00

I want to format the numbers so that it gets displayed in proper format.

  • 0

I want to format the numbers so that it gets displayed in proper format. At the moment 1-12 left side is displaying correctly apart from 1 because it has moved into another space due to pushing the 8 into the format.

The Wrong outcome is shown below… The (-) act as spaces on here because I cant attach an image.

--1 * 8 = -8
-2 * 8 = 16
-3 * 8 = 24
-4 * 8 = 32
-5 * 8 = 40
-6 * 8 = 48
-7 * 8 = 56
-8 * 8 = 64
-9 * 8 = 72
10 * 8 = 80
11 * 8 = 88
12 * 8 = 96

The outcome I want is shown below… The (-) act as spaces on here because I cant attach an image.

--1 * 8 = --8
--2 * 8 = 16
--3 * 8 = 24
--4 * 8 = 32
--5 * 8 = 40
--6 * 8 = 48
--7 * 8 = 56
--8 * 8 = 64
--9 * 8 = 72
10 * 8 = 80
11 * 8 = 88
12 * 8 = 96

I appreciate if anyone can help me with this… has been driving me insane.

Here is my code so far:

  public class Main {

        public static void main(String [] args) {

            int end_value = 13;
            int result = 0;

            System.out.print("Enter a Number:");
            int num_input = BIO.getInt();

            for (int numberLoop = 1; numberLoop < end_value; numberLoop++) 
            {
                result = numberLoop * num_input;

                System.out.printf("%11s\n", numberLoop + " * " + num_input + 
                                                          " = " + result);
            }
        }
    }
  • 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-12T11:39:21+00:00Added an answer on June 12, 2026 at 11:39 am

    You should apply formatting on individual elements : –

    System.out.format("%3d * %4d = %5d\n", numberLoop, num_input, result);
    

    And you should use %d as you are printing integers..

    %3d will be replaced by numberLoop.

    %4d will be replaced by num_input

    %5d will be replaced by result

    And you will get the output like: –

    numberLoop(3 spaces) * num_input(4 spaces) = result(5 spaces)
    

    %3d is for right justification.. and %-3d is for left justification.. You can use either of them..

    You can also store your formatted string into a String variable by using String.format(), and you can later print that string variable: –

    String result = String.format("%3d * %4d = %5d\n", numberLoop, num_input, result)
    

    NOTE: – For more formatting options, you can go through documentation of Formatter class..

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

Sidebar

Related Questions

Hi I want to format float numbers such that it will be displayed as
I want to extract valid(on the basis of format) mobile numbers from a text.
I want to change my NSNumberformatter from displaying negative numbers with parenthesis around them
I want to make a program that will read some number in string format
I want to format my numbers throughout the application in a consistent way, no
Hey guys, I have an application that I want to display some data from
Column B contains the numbers 17, 1408 and some numbers that have this format
Hey guys. I have a method that gets called each second which I want
I am trying to conditionally format the numbers that appear in a NumericAxis axis
I want to pick a random number and express that number in the format

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.