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 display the array: public static void printMultiplicationTable(int table[ ][ ], int x, int y)
You must load the table array with products of the factors. For example:
In Figure 1 above, the 5 x 5 array is loaded with the products for the times tables from 4 to 8
In Figure 2 above, the 2 x 2 array is loaded with the products for the times tables from 5 to 6
GENERAL RESTRICTIONS FOR ALL QUIZZES, MIDTERM AND FINAL EXAM
No global variables
No infinite loops, examples include:
for(;;)
while(1)
while(true)
do{//code}while(1);
No break statements to exit loops
No labels or go-to statements
If you violate any of these restrictions, you will automatically get a score of ZERO!
Program:
import java.util.Scanner;
public class MultiplyProgram
{
public static void loadArray(int table[][], int x, int y)
{
for(int r=x,p=0; p<=table.length-1; r++, p++)
{
for(int c=x, q=0; q<=table.length-1; c++,q++)
table[p][q] = r*c;
}
}
public static void printMultiplicationTable(int table[][], int x, int y)
{
System.out.print(" ");
for(int r=x; r<=y; r++)
System.out.print(r+"\t");
System.out.println("\n----------------------------------------------------");
for(int r=x,p=0; p<=table.length-1; r++, p++)
{
System.out.print(r+"\t");
for(int q=0; q<=table.length-1; q++)
System.out.print(table[p][q]+"\t");
System.out.println();
}
}
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter the starting value \n");
int x = s.nextInt();
System.out.print("Enter the ending value \n");
int y = s.nextInt();
int m;
m = y-x+1;
int[][] table= new int[m][m];
loadArray(table, x, y);
printMultiplicationTable(table, x, y);
s.close();
}
}
Output:


Write a program which: Prints out the Multiplication Table for a range of numbers (positive integers)....
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...
In Java
Write a program that reads an arbitrary number of 25 integers that are positive and even. The program will ask the user to re-enter an integer if the user inputs a number that is odd or negative or zero. The inputted integers must then be stored in a two dimensional array of size 5 x 5. Please create 3 methods: 1. Write a method public static int sum2DArray( int [1] inputArray ) The method sums up all elements...
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...
In Java*
Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
Write a program that stores a phrase as an array of words, and then prints it backwards. The main method calls method getInput , which asks the user how many words there are, stores them in an array, and returns this array. printBackwards then takes this array of words, and prints it in reverse. Code Example: import java.util.Scanner; public class L17Num1{ public static void main(String[] args) { String[] sArray=getInput(); printBackwards(sArray); } public static String[] getInput() { System.out.println("How many...
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?
Need help figuring this out Write a program that reads in a sequence of numbers (doubles) from standard input until 0 is read, and stores them in an array, This part is done using iteration (loop). You may assume that the maximum size of the array will not be more than 100. Your program computes the maximum number stored in the array, the count of negative numbers, and computes the sum of positive numbers, using recursion. You need to have...
1. Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. You can assume that all numbers are valid. For example: Input Result 140 -5 10 Enter a number: Enter a number: Enter a number: -5, 10, 140 import java.util.Scanner; public class Lab01 { public static void main(String[] args) { Scanner input = new Scanner(System.in); } } ---------------------------------------------------------------------------------------------------------------------------- 2. Write a program that repeatedly prompts the user for integer values from...
Write a program that instantiates an array of integers named scores. Let the size of the array be 10. The program then first invokes randomFill to fill the scores array with random numbers in the range of 0 -100. Once the array is filled with data, methods below are called such that the output resembles the expected output given. The program keeps prompting the user to see if they want to evaluate a new set of random data. Find below...
Write a while loop that prints all positive numbers that are divisible by 10 and less than a given number n. For example, if n is 100, print 10 20 30 40 50 60 70 80 90. import java.util.Scanner; public class PositiveLess { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("n: "); int n = in.nextInt(); ... while (...) { ...