Build a program that will ask the user to enter two numbers to be used as the
Question:
Build a program that will ask the user to enter two numbers to be used as the dimensions of their multiplication table (one is rows and the other is columns). Based on these input values, your program will print the multiplication table to the console in a well formatted way so it is easy to read.
Required Skills and Outcomes: To complete this assignment, you will need to: obtain user input to get the input numbers ensure input is valid using repeated prompts apply nested looping to produce a multiplication table based on the input format the output in a desired manner
1. You first need to get the two inputs from the user. The program should only accept values between 1 and 20. If a value outside this range is entered, prompt the user again. (Hint: do-while loops are great for ensuring a specific value is attained)
2. Based on the inputs from the user for rows and columns of the table, you will need to print out the multiplication table such that each cell contains the product of the row and col values, thus creating a full multiplication table. The table will always begin at multiples of 1.
3. When printing the values, to ensure they align nicely, you should ensure that each number takes up exactly 4 spaces (right aligned), with no spaces between the numbers printed (aside from those imposed by the 4 space rule) Since the maximum value (20 * 20) is only 3 digits (400), there will be no issues with the numbers crowding each other.
import java.util.Scanner;
public class TheTimesTheyAreALoopin { public static void main(String[] args) { Scanner in = new Scanner(System.in); int total = 0; int numOfNums = 20; Sysyem.out.println("You will enter a value " + numOfNums + " I will calculate their multiplication."); int x = 1; while (x <= 20); { System.out.println(x); x = (int) (x * 1); } Syetem.out.prinlnt("The total is " + total); } }
This is my code, please point out my error and hopefully provide a solution, thank you.
The Science And Engineering Of Materials
ISBN: 9781305076761
7th Edition
Authors: Donald R. Askeland, Wendelin J. Wright