Question: Write a Java program that reads a positive integer entered by the user and then prints out all the positive divisors of that integer in
Write a Java program that reads a positive integer entered by the user and then prints out all the positive divisors of that integer in a column and in decreasing order. The program should allow the user to repeat this process as many times as the user likes. When the user accidentally enters a zero or negative integer to have its divisors calculated, the program should inform the user that the input is unacceptable and should allow the user to try again (and again!). In other words, provide data validation for the user input. The program should prompt the user for each integer that the user wishes to enter. The program may be terminated (after an integer has been entered and the divisors have been printed). The program then asks the user whether he/she wishes to enter another integer. Use a Yes or No question to get the users response. NOTE: you will need a call to your Scanners nextLine method prior to reading in your users response. This is because Scanners nextInt method does not read in or consume the new line character when the user hits the Enter key. This program will require three loops: A data validation loop A loop to print out the divisors A continue working Y or N loop The Continue working loop will be the outer loop. The other loops will be inner loops. Sample output is provided below: Enter a positive whole number: -44 Enter a positive whole number: 43 43 1 Continue? Enter Y or N qwerty Enter a positive whole number: 0 Enter a positive whole number: -4 Enter a positive whole number: 46 46 23 2 1 Continue? Enter Y or N y Enter a positive whole number: 2476 2476 1238 619 4 2 1 Continue? Enter Y or N
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
