One - Dimensional Arrays (50 points)
Write an applet which will find the sum of the first n positive integers.
Use a for loop to fill the integers into a one - dimensional array as follows :
num = 1, num = 2, num = 3 ... num[n-1] = n.
Use a second for loop to find the sum, and a third to dump out the array list.
Output each term in equation form with no more than five terms per line. The last
term must not be succeded by a plus symbol. If a non positive integer is entered,
make sure you output an error message.
If 14 is entered then output :
1 + 2 + 3 + 4 + 5 +
6 + 7 + 8 9 + 10 +
11 + 12 + 13 + 14 =
If 0 or any other non positive integer is entered then output :
You must enter a positive integer.
Please try again.
- Document your applet. Include your Name, Date, Project#, and a
description of the project.
- Test your results with a calculator.
- Input the data with the TextField class
- Output your result with the TextArea class.
Sample Output for Project40