Question
In Java 1. Write a program that prompts the user for a positive integer . If the user does not enter a positive integer, keep
In Java
1. Write a program that prompts the user for a positive integer. If the user does not enter a positive integer, keep prompting them (using a WHILE loop) until they enter proper input (so, for example, if they enter -5, it should re-prompt because the value is not positive).
Once the user has entered a positive integer, n, use a FOR loop to output the factorial of n.
Recall, n! = n * (n-1) * (n-2) * ... * 3 * 2 * 1.
2. Write a program that prompts two positive integers m, n from the
console and outputs a multiplication table of the size m x n.
For each row: Print each row with a header of the row number, tab, |, and tab. Print each row with the row number times column number, followed by tab. (Use another for loop). Finally print a new line.
Print Header row: *, tab, |, column umber, tab, column number, tab ..., newline Print s. Hint: Use tabs. Each tab is 8 spaces, so you need to write eight -.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started