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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:12:38+00:00 2026-05-27T06:12:38+00:00

This is not homework. I am a beginner (novice) java programmer, trying to read

  • 0

This is not homework. I am a beginner (novice) java programmer, trying to read and complete the exercises at the end of ivor horton’s beginning java book.

Write a program to create a rectangular array containing a multiplication table from 1 X 1 to 12 X 12. Output the table as 13 columns with the numeric values right aligned in columns. (The first line of output will be the column headings, the first column with no heading, then the numbers 1-12 for the remaining columns. The first item in each of the succeeding lines is the row heading which ranges from 1-12.

NOTE: I have only learned about Arrays & Strings, Loops & Logic, data types, variables, and calculations. I have not learned about classes and their methods and etc……so no fancy stuff please. THANKS!

public class Chapter4Exercise2 {

    public static void main(String[] args)
    {

     int[][] table = new int[12][12];


     for(int i=0; i <= table.length-1; i++)
     {
        for (int j=0; j <= table[0].length-1; j++)  
        {
        table[i][j] = (i + 1) * (j + 1);
        if (table[i][j] < 10) 
         System.out.print("  " + table[i][j] + " ");        
        else
        if (table[i][j] > 10 && table[i][j] < 100)          
         System.out.print(" " + table[i][j] + " "); 
        else
         System.out.print(table[i][j] + " ");       
        }
        System.out.println(" ");
     }

    }
}
  • 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-27T06:12:39+00:00Added an answer on May 27, 2026 at 6:12 am

    As long as the numbers are less than 1000, try this:

    As @Mr1158pm said:

    public class Chapter4Exercise2 {
      public static void main(String[] args) {
    
      int tableSize = 10;
    
      int[][] table = new int[tableSize][tableSize];
    
      for(int i=0; i < table.length; i++) {
        for (int j=0; j < table[i].length; j++) {
          table[i][j] = (i+1)*(j+1);
    
          if(table[i][j] < 10) //Where i*j < 10
            System.out.print("   "+(table[i][j])+" ");  
          else if(table[i][j] < 100) //Where i*j < 100
            System.out.print("  "+(table[i][j])+" ");
          else //Where i*j < 1000
            System.out.print(" "+(table[i][j])+" ");
        }
      System.out.println("");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve this problem, its not a homework question, its just code
This is NOT a homework. I'm a beginner in programming, and also this is
This is not homework, I need this for my program :) I ask this
Please note that this is not homework and i did search before starting this
this one is not homework, it just the fact that i've been out of
This one is a case of not doing your homework.:-) Apart from dynamic loading
Disclaimer: This is for a homework assignment, but the question is not regarding the
Ok this is a homework questions, but I cannot find the answer anywhere, not
This is not homework. I saw this article praising Linq library and how great
First of all this is not homework, I'm in a desperate need for a

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.