To work with
In this exercise, you let the user enter a whole number, assumed to be in range 0-100, that represents an exam score. The program should print out the letter grade for the exam: A for 90-100, B for 80-89, C for 70-79, D for 60-69 and F for 0-59.
Newton's method consists of approximating the actual square root of a given number by means of a sequence of approximations. The first approximation is simply a guess - we'll use 1 as the first guess. Then at each iteration, we obtain the next guess from the current guess by computing (guess +number/guess)/2.
First write a program that allows the user to enter a positive real number and the number of iterations to use. The program should then print out the sequence of guess's (approximations). Once this finishes, the program should print out the square root as given by the Java method, Math.sqrt - have the program print the value of Math.sqrt(number) for comparison. The starting point is the project Newton in the Lab3 folder.
Once you have this program working, change the program so that the user may continue to give sets of input until he/she indicates that they have finished.
Be sure to follow all of our guidelines for programming style.
(This exercise is taken from Chapter 5, Programming Problem 5. )
The starting point for this program is the project Perfect in the Lab3 folder.
First write a program that takes as input a positive integer, num, and prints out the sum of the divisors of num, not including num itself. For example, if the user enters a value of 10 for num, then the program should print out the value 8, since the proper divisors of 10 are 1, 2, and 5. Test your program several times.
A perfect number is a number which is equal to the sum of its proper divisors. For example, the number 6 is perfect. Change your program so that it simply tells whether or not the number given by the user is perfect. Test you program several times. Can you find any more perfect numbers?
Now change your program so that the user inputs a positive number, limit. The program should then print out all of the perfect numbers that are less than or equal to limit. So, if the user enters 1000, the program should print out all of the perfect numbers that are less than or equal to 1000.
A number is deficient if the sum of its proper divisors is less than the number (8 is deficient), and is abundant if the sum exceeds the number (24 is abundant). Change your program so that it still lists the perfect numbers that if finds, but also tells how many of the numbers checked were deficient, how many were perfect, and how many were abundant.
When you have completed all work on this lab, you should turn in to me print outs of your final programs. Be sure that you have comments with your information at the top of the programs.
You should also copy your Lab3 folder into your turnin folder.