Answer to Question #308032 in Java | JSP | JSF for Hlo Makiwane

Question #308032

PROGRAM 3 – Times tables




You must write a small application in JAVA that will read in a positive integer and then display the times tables for that number, from 1 to 12.



Your program must




1. Read in the integer as input.




2. Calculate and display the complete times tables up to 12 for that integer.




3. If a zero or any number less is entered, an error message must be displayed and the user must be allowed to input another value.




1
Expert's answer
2022-03-10T07:15:24-0500


import java.util.*;


class App {


	public static void main(String[] args) {
		Scanner keyboard = new Scanner(System.in);
		int n = -1;
		while (n < 1) {
			System.out.print("Enter the integer number: ");
			n = keyboard.nextInt();
			if (n < 1) {
				System.out.println("Wrong the integer number! Try again. ");
			}
		}


		for (int i = 1; i <= 12; ++i) {
			System.out.println(n + " * " + i + " = " + n * i);
		}
		keyboard.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS