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.
• Write a Java program that reads in an integer and prints all subrange sums that is equal to the integer.
The output of the program looks something like this when the user enters the integer 1986:
```	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
Done
```
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 ``pj2.java'' available 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.

```	/home/cs170001/turnin  pj2.java  pj2