You must do this assignment using Eclipse and the ThatsPerfect project that you checked out from your individual SVN repository in class.
Be sure to check out that project into your Eclipse C workspace, not your Python workspace.
(5 poins) Now, edit the
main()
function so that it uses a sentinel while loop, printf(), and scanf() to prompt the user to enter integers. Exit the loop when the user enters a negative number. Otherwise, just print the value the user entered and prompt for another number.
When you have this part working, commit it to your repository and go on to the next step.
(15 points) A perfect number is one that is the sum of its factors. For example, 6 and 28 are perfect because 1+2+3=6 and 1+2+4+7+14=28. But 24 is not perfect because 1+2+3+4+6+8+12 is not 24.
Define a function
int isPerfect(int n)
that returns 1 if n is perfect and 0 if it is not perfect.
Do not attempt to find a closed-form solution. Instead, actually compute the factors of n and add them together.
while loop you created in step 5 so that it prints whether or not the entered number is perfect. A sample run of the program might be: Enter an integer (negative to quit): 6 6 is perfect. Enter an integer (negative to quit): 24 24 is not perfect. Enter an integer (negative to quit): 28 28 is perfect. Enter an integer (negative to quit): -1 Goodnight, Gracie.
When you have this part working, commit it to your repository and go on to the next step.
(10 points) The first two perfect numbers are 6 and 28. Modify your program so that after the interactive part, but before exiting, it calculates and prints the fourth perfect number. This number is quite large, so your program might take a while to run.
When you have this part working, commit it to your repository and enjoy a refreshing beverage.