Hello, I'm new to java and am completely lost in this program I am supposed to create.
This program should have six methods:
intro ()
This method will output a welcome message to the user.
getRows()
This method will ask the user for the number of rows they would like in their multiplication table. It will set the row array to the size the user requests.
getCols()
This method will ask the user for the number of columns they would like in their multiplication table. It will set the column array to the size the user requests.
fillRows()
This method will fill the row array with the numbers to be used to multiply against the column array to get the multiplication table.
fillCols()
This method will fill the column array with the numbers to be used to multiply against the row array to get the multiplication table.
printTable()
This method will print the size of the table, the headers for the columns and rows, as well use for loops to print the multiplication table
the output should be like
Welcome to the Multiplication Table Program!
Enter number of rows:6
Enter number of columns:4
Here is your 6 x 4 multiplication table:
1 2 3 4
---------------------------
1| 1 2 3 4
2| 2 4 6 8
3| 3 6 9 12
4| 4 8 12 16
5| 5 10 15 20
6| 6 12 18 24
Here's what I've got so far:
import java.util.Scanner; public class MultTable { public static void main ( String args[] ) { int[] rows; int[] cols; } public void intro(); { System.out.println("Welcome to the Multiplication Table program!"); } public int getRows(int[] rows) { int numr; Scanner input = new Scanner(System.in); System.out.print("Enter number of rows: "); numr = input.nextInt(); } public int getCols(int[] cols) { int numc; Scanner input = new Scanner(System.in); System.out.print("Enter number of columns: "); numc = input.nextInt(); } public int fillRows(int[] rows); { } public int fillCols(int[] cols); { } public int printTable(int[] cols, int[] rows); { for(int i = 1; i < rows.length; i++) { rows[i] = i; } for(int j = 1; j < cols.length; j++) { cols[j] = j; } } }
I am unsure of how I should tackle the fillRows() and fillCools() methods. I have a relative idea of what the printTable() should be like, but other than that, I am lost.
I would be grateful to anyone who can help through this.