Question

Write an algorithm that prints a multiplication table for up to 9 times 9. As an example, a multiplication table up to 3 times 3 looks like: 4 6 How might you change your algorithm to allow the user to specify the size of the table?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

///////////////////////////LOGIC WITH CODE/////////////////////////////

import java.util.Scanner;

public class Table {

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.print("Enter no of tables you want\t:");

Scanner sc=new Scanner(System.in);

int m=sc.nextInt();

System.out.print("Enter upto what you want\t:");

int n=sc.nextInt();

System.out.println();

for(int i=1;i<=m;i++){

for(int j=1;j<=n;j++){

System.out.print((i*j)+"\t");

}

System.out.println();

}

}

}

/////////////////////////////////OUTPUT FOR 3X3//////////////////

Enter no of tables you want Enter upto what you want :3 :3 2

///////////////////////////////////OUTPUT FOR 9X9///////////////////////////

/////////////////////////////////MAIN ALGORITHM LOGIC SUDO CODE WITH SCREENSHOT////////////////////

//////////////////////////////////////////////////ALGORITHAM///////////////////////////

1.take input for no of tables you want

2.take input for upto what you want to print

3.to print for 1 table

suppose 5th table

5x1 5x2 5x3 5x4 5x5 .................

5 10 15 20 25..............

we can use for loop for this....

like this this is for one looop

to print all we need another looop

a.one loop for no of tables

b.another table for upto what you want to print

Add a comment
Know the answer?
Add Answer to:
Write an algorithm that prints a multiplication table for up to 9 times 9. As an...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program which: 1. Prints out the Multiplication Table for a range of numbers (positive...

    Write a program which: 1. Prints out the Multiplication Table for a range of numbers (positive integers). • Prompts the user for a starting number: say 'x' • Prompts the user for an ending number: say 'y' • Prints out the multiplication table of 'x' up to the number 'y' SPECIFIC REQUIREMENTS 1. You must use the following method to load the array: public static void loadArray(int table[][], int x, int y) 2. You must use the following method to...

  • Write a program which: Prints out the Multiplication Table for a range of numbers (positive integers)....

    Write a program which: Prints out the Multiplication Table for a range of numbers (positive integers). Prompts the user for a starting number: say 'x' Prompts the user for an ending number: say 'y' Prints out the multiplication table of 'x' up to the number 'y' Sample outputs include:    SPECIFIC REQUIREMENTS You must use the following method to load the array: public static void loadArray(int table[ ][ ], int x, int y) You must use the following method to...

  • In C++ The Multiplication Program Step 1: Write a program that stores a multiplication table in...

    In C++ The Multiplication Program Step 1: Write a program that stores a multiplication table in a 9-by-9 two-dimensional array. Generate the multiplication table with two loops. (So you will have a nested loop that will iterate 9 times and fill the 9x9 array with the values.) Step 2: Display the table for the user to see it. a 9x9 table Step 3: Create a function that returns the product of two numbers between 1 and 9by looking up the...

  • Write a program that prints out multiplication table: 1. In the main loop, it should ask...

    Write a program that prints out multiplication table: 1. In the main loop, it should ask a user to enter a number in the range of 1 to 12. Exit the program upon input out of range (eg., 0 or 13). 2. Output the multiplication table from 1 to 12. Possible output: Enter the number (1-12): 9 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5...

  • Using java E6.17 Write a program that prints a multiplication table, like this: 1 2 3...

    Using java E6.17 Write a program that prints a multiplication table, like this: 1 2 3 4 56 7 8 9 10 2 4 6 8 10 12 14 16 18 20 3 6 9 12 15 18 21 24 27 30 10 20 30 40 50 60 70 80 90 100

  • Q.2)) (12.5 marks) Write a program which prints a multiplication table (i.e. 1*n=2, 2*n=?.... 12*n=?). Allow...

    Q.2)) (12.5 marks) Write a program which prints a multiplication table (i.e. 1*n=2, 2*n=?.... 12*n=?). Allow the user to determine which table (value of n) they require and draw the flowchart.

  • Please answer it by easy JAVA pseudocode. Thanks Write a pseudocode algorithm that calculates and prints...

    Please answer it by easy JAVA pseudocode. Thanks Write a pseudocode algorithm that calculates and prints the overall MPG (miles per gallon) for a series of miles and gallons user inputs. Use a loop to repeatedly ask the user to enter a miles value and a gallons value. Within the loop, accumulate miles and gallons separately. Use a counter loop to ensure that the loop repeats three times. The algorithm should generate a display of prompts, inputs, and final output...

  • In VS if you can please!! Multiplication write a program that executes the multiplication of two...

    In VS if you can please!! Multiplication write a program that executes the multiplication of two numbers entered by the user using only the addition operation. For example, if the user enters 3 and 4, the program computes the multiplication of these numbers by adding the number 4 three times (i.e., 3 * 4 = 4 + 4 + 4). Solve this problem in the most efficient way.

  • Java Submit a program in a .java file. The program should print a multiplication table for...

    Java Submit a program in a .java file. The program should print a multiplication table for the numbers 1-9. This requires a nested for loop. The outer loop moves from row to row, while the inner loop prints the row. Use tabs to separate the output, such as in the following statement:      System.out.println(“1\t2\t3\t4\t5\t6\t7\t8\t9”); Output should look similar to the following. 1      2     3     4     5     6     7     8     9 ------------------------------------------------------------------ 1       2     3     4     5     6        7     8     9...

  • Python: Write a code to ask a number (one digit) from the user and prints the...

    Python: Write a code to ask a number (one digit) from the user and prints the respective row of the multiplication table. For example, if the user enters 5, the following lines will be printed. Note that, if the user enters any number outside the range of 1-9, the program should display an error message. 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT