Question: Could you do #6-10 & all the parts within them. 2. Create the main method 3. Inside, create these variables: a. Create an int called

2. Create the main method 3. Inside, create these variables: a. Create an int called numTocheck and assign to it any positive integer from 2-1000 (Please refer to the PE Clarification Thread on Ed for example output.) b. Create an int called numFactors and assign to it the value 2. This will keep track of the number of integers that are factors of numToCheck. c. Create an int called smallestFactor and assign to it numTocheck. This will keep track of the smallest factor bigger than 1. d. Create an int called currentFactor and assign to it the value of numTocheck - 1. 4. Print "Checking if [numTocheck] is prime..." 5. Create a while loop that terminates when currentFactor is less than 2 . 6. Within the while loop, use an if-else statement to do the following: a. If currentFactor divides numToCheck, do the following: i. Use a printf statement to output: "[currentFactor] divides [numTocheck]" ii. Check whether currentFactor is less than smallestFactor. If so, update smallestFactor. iii. Increment numfactors by 1. b. Otherwise, use a printf statement to output: "[numTocheck] is not a multiple of [currentFactor]" 7. Decrement currentFactor by 1 . 8. Close the while loop 9. After the while loop, use two print statements to output the following on separate lines: a. "Number to check for primality: [numTocheck]" b. "Smallest factor: [smallestFactor]" 10. Finally, use a switch statement to print one of the following statements according to the value of numFactors: a. 2 factors: "The number is prime!" b. 3 factors: "This number has three factors, so it is not prime." c. 4 factors: "This number has four factors, so it is not prime." d. 5 factors: "This number has five factors, so it is not prime." e. All other amounts (using printf): "Wow, [numFactors] is a lot of factors! This number is not prime." (For example, if 8 , "Wow, 8 is a lot of factors! This number is not prime." should be printed without the quotes.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
