/*
* File: FindRange.java
* --------------------
* This program is a stub for the FindRange problem, which finds the
* smallest and largest values in a list of integers.
*/
import acm.program.*;
public class FindRange extends ConsoleProgram {
/* define your constants here. (like your SENTINEL value) */
public void run() {
// You fill this in
println("This program finds the largest and smallest numbers.");
int a = readInt("?");
int min = a, max = a;
while (a != 0) {
if (a > max)
max = a;
if (a < min)
min = a;
a = readInt("?");
}
println("smallest: " + min);
println("largest: " + max);
}
}
* File: FindRange.java
* --------------------
* This program is a stub for the FindRange problem, which finds the
* smallest and largest values in a list of integers.
*/
import acm.program.*;
public class FindRange extends ConsoleProgram {
/* define your constants here. (like your SENTINEL value) */
public void run() {
// You fill this in
println("This program finds the largest and smallest numbers.");
int a = readInt("?");
int min = a, max = a;
while (a != 0) {
if (a > max)
max = a;
if (a < min)
min = a;
a = readInt("?");
}
println("smallest: " + min);
println("largest: " + max);
}
}