CS 123 I2P Assignment 2
CS 123 I2P Assignment 2
CS 123 I2P Assignment 2
Write a program that prompts the user for an integer and then prints out all coward numbers up to
that integer. For example, when the user enters 20, the program should print: 3 4 6 8 12 14 18 20.
Recall that a number is a prime number if it is not divisible by any number except 1 and itself.
Hint: Use Nested Loop to solve this problem. Outer Loop iterations must start from 3 and ideally inner
loop iterations must start from 2.
Coward Number: Number whose previous number is not divisible by any number other than 1
and number itself.
Instructions:
1. Create a program called CowardNumbers.java.
2. Create appropriate variables and assign values using a Scanner object.
3. Correctly display appropriate messages.
4. Use Correct Indentation.
5. Submit .java file only.
Write a program that asks the user to enter three positive integer value; number, start, end and
Silicon Value, and then prints the Silicon table of the number from the starting number to the ending
number. After printing the table, our program should ask the user whether he or she wishes to perform
the operation again. If so, the loop should repeat; otherwise it should terminate.
Use a character input of y or Y to repeat, and n and N to terminate the loop. No break statement is
allowed.
NOTE: Perform input validation so that all numbers must be greater than 0 and the “start” number
should be less than “end” number.
NOTE: Silicon Number is multiplied with iteration counter as shown in the table below.
Sample Output:
Enter a number: 5
Enter starting value: 3
Enter ending value: 7
Enter silicon value: 9
Silicon Table:
5 * 3 * 9 = 135
5 * 4 * 18 = 360
5 * 5 * 27 = 675
5 * 6 * 36 = 1080
5 * 7 * 45 = 1575
Do you want to repeat this operation again? (Press y/Y to repeat and n/N
to stop): Y
Enter a number: 6
Enter starting value: 5
Enter ending value: 6
Enter silicon value: 8
Table:
6 * 5 * 8 = 240
6 * 6 * 16 = 576
Do you want to repeat this operation again? (Press y/Y to repeat and n/N
to stop): n