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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:08:14+00:00 2026-06-15T13:08:14+00:00

I have an assignment to create a program that prompts user input of an

  • 0

I have an assignment to create a program that prompts user input of an integer, then creates a multiplication table based on the user input using while loops.

The output multiplication table must include header row and column. What I’m stuck on is how to create the header row since the number that the header must count up to is dependent on the user input.

I created the header column in the while loop that formats the rows since a new row is created each time the loop gets stepped through. But the header row only prints once and therefore I cant use the while loop that formats the columns to create it.

How do I create the header row such that the user input is decremented back to 1, and all of the integer values from 1, 2, 3, … , user input are output?

Here’s what I have:

import java.util.Scanner;
public class Multiplication
{
    public static void main(String[] args)
    {
    int number;
    String yesno = "Y";
    Scanner keyboard = new Scanner(System.in);
    System.out.print ("This program generates a multiplication table ");
    System.out.println("based on a number you enter.");


    while(yesno.equalsIgnoreCase("Y"))
    {
        System.out.println("Please enter a number.");
        number = keyboard.nextInt();

        int row = 1;
        int column = 1; 

        System.out.println(" |" + MAKETHISWORK + "\t"); //THIS IS WHERE I'M STUCK.
        System.out.println("--------------------");          

        while(number>0)  
        {     
            row = 1;
            while(row <= number)
            {
                System.out.print(row + "|");

                column = 1; 
                while(column <= number)
                {

                    System.out.print(row*column + "\t");   
                    column ++;

                } //END WHILE COLUMN <= NUMBER
                System.out.println();
                row ++;

            } //END WHILE ROW <=NUMBER
            System.out.println();

            while(number>0)
            {
                number--;
            }

        } //END WHILE NUMBER >0

        System.out.println("Would you like to enter another number? (Y/N) ");
        yesno = keyboard.nextLine();
        yesno = keyboard.nextLine();
    } //END WHILE YESNO IS Y

    while(yesno.equalsIgnoreCase("N"))
    {
        System.out.println("Thanks for participating!");
        break;
    }
}
}
  • 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-15T13:08:16+00:00Added an answer on June 15, 2026 at 1:08 pm

    Why not just use another loop to build up a string to that value?

    StringBuilder builder = new StringBuilder();
    for (int i = 1; i <= number; i++) {
        builder.append(i).append(" ");
    }
    System.out.println(" |" + builder.toString() + "\t");
    

    Note this will create a space-delimited string of the numbers up to the input one. If you want a different delimiter, just append a different value.

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

Sidebar

Related Questions

For a school assignment I have to create a C++ program that will create
The assignment was to create a program that computes the Ackermann equation using recursion,
I have an assignment to create a program that converts deci (-32,768 through 32,767)
For a homework assignment, I have to create a simple program that takes two
I have an assignment to create a GUI using MATLAB GUIDE and am having
I have a programming assignment and we are asked to create a program in
I have an assignment where my program outputs a simple String using if conditions
I've been given an assignment to create a program that might involve a quiz
I have an assignment that I have to create a randomly sized 3D array,
I have an assignment for uni where I have to create a Java program

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.