CISC 1115
Introduction to Programming Using Java
Lab #10
Techniques II

How to Develop and Submit your Labs

Lab 10.1 — Totalling Above and Below a Threshold (ThresholdTotals)

The file values.text consists an initial threshold value (an integer) followed by a sequence of integers. Read in the integers (until eof) and keep a total of those numbers above (or equal to) the threshold, and those below, printing out the sums after all integers have been read in.

Sample Test Run

For example if the file values.text contains:

50
23
67
50
13
23
the program should produce the following output:
The sum of the values above the threshold of 50 is 117
The sum of the values below the threshold of 50 is 59

Lab 10.2 — Totalling Up To 100 (Until100)

Read in and total values from the keyboard, stopping onc the total reaches 100, and printing out the last value of the total before it reached 100.

Sample Test Run

Here is a sample execution of the program.
User input is in bold. Your program should replicate the prompts and output:

Enter a number: 80
Enter a number: 10
Enter a number: 15
2 numbers were read in with a total of 90 before 100 was reached

Lab 10.3 — Counting Above and Below a Threshold (ThresholdCounts)

The file values.text consists an initial threshold value (an integer) followed by a sequence of integers. Read in the integers (until eof) and keep a count of those numbers above (or equal to) the threshold, and those below, printing out the counts after all integers have been read in.

Sample Test Run

For example if the file values.text contains:

50

23
67
50
13
23
the program should produce the following output:
The number of values above the threshold of 50 is 2
The number of values below the threshold of 50 is 3

Lab 10.4 — Finding the Last Occurrence of a Value in a File (FindLast)

Write a program that prompts the user for a value and searches the file numbers.text for that value, printing out the last position where the number appears in the file (the first number in the file is at position 1). If the number does not appear in the file, print out an appropriate message. Prompting the user for values should repeat until end of file. Sample Test Run

For example if the file numbers.text contains:

10
23
43
5
12
23
9
8
10
1
16
9
execution of the program should look like:

Enter a number: 10
10 last appears in the file at position 9
Enter a number: 29
29 does not appear in the file
Enter a number: 9
9 last appears in the file at position 12
Enter a number:

Some Guidance and Notes