CS170 - Project 2
CS170, Project 2
Due: See class webpage
1. Subrange Sum
A subrange sum is the sum of two or more consecutive integers.
For example, 1+2, 4+5+6, 1000+1001+1002+1003, etc, are subrange sums.
The output of the program looks something like this when the user enters
the integer 1986:
Write a Java program that reads in an integer and
prints all subrange sums that is equal to the integer.
Enter number = (you enter 1986)
1986 is the subrange sum of 160..171
1986 is the subrange sum of 495..498
1986 is the subrange sum of 661..663
Check for yourself that:
- 160+161+162+163+164+165+166+167+168+169+170+171 = 1986
- 495+496+497+498 = 1986
- 661+662+663 = 1986
2. cs170 Project directory
Each student enrolled in this course has a special project directory
named cs170 in their home directory.
You must work in the project directory to ensure that your
work is protected unauthorized access.
After you login to the UNIX system, you execute the command
``cd cs170'' to enter your project directory.
3. Help file
To help get you started with this program, I made the file
on this webpage (click on the link).
Click on "File" in your Netscape browser and select "Save As".
Save a copy in your cs170 project directory.
Then use vi (or your favorite editor)
to expand it into the solution for this assignment.
This project will use the ConsoleReader class to
input integer numbers.
You will also need to put a copy of the
ConsoleReader.java file in
your project directory.
You can get a copy of the ConsoleReader.java program
at this hyper link:
Follow the link above and then click on "File" in your Netscape browser
followed by "Save As" to save a copy in your cs170
4. Turn in