Question

Ask the user to enter a number.
Using the while statement to create a multiplication table, using the input as a guide. For instance, if the user enter's 3, then create a 3 x 3 multiplication table.
Display the table in this format:
   | 1   2   3
-------------
1|   1   2   3
2|   2 4   6
3|   3 6   9

Repeat the program until the user chooses to quit.
Submit your source code as a plain text file with a .java extension.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

public class MultiplicationTable {

public static void main(String[] args){
// initialize the scanner
Scanner inputScanner = new Scanner(System.in);

// prompt the user for input
System.out.print("Please enter a number or the letter \"q\" to quit:");

// get user input
String userInput = inputScanner.next();

// as long as the user did not select to quit by typing "q" or "Q"
while(!userInput.equalsIgnoreCase("q")){
// convert the user input to an integer
int userNumber = Integer.parseInt(userInput);


// print the start of the header row
System.out.print(" |");

// followed by 1..userNumber in a sequence, with a space between each
for(int i=1; i <= userNumber; i++){...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Arrays in Programming Language Java
Homework Solution
$20.00
Java
Programming
Computer Science
Arrays
Integers
Random Numbers
Methods
Functions
Even Elements
Odd Elements
Prime Numbers
Minimum Values
Maximum Values
Average Values
Loops
Conditions
Statements
Accounting Problems Using Java
Homework Solution
$45.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Input
Output
Integers
Interest Rates
Account Balance
Display Messages
Compounding Interest
Strings
Dates
Analysis
Java Programming Problems
Homework Solution
$15.00
Java
Computer Science
Programming
Algorithms
Coding
Prime Factors
Run Length Encoding
Strings
Decimals
Flag Characters
Conversions
Java Programming Problems
Homework Solution
$38.00
Java
Programming
Computer Science
Palindromes
Methods
Functions
Loops
Input
Output
Insertion Sort
Algorithms
Arrays
Integers
Strings
Get help from a qualified tutor
Live Chats