FindRange - print"" int x=readInt i...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * File: * Name: * Section Leader: * -------------------- * This file is the starter file for the FindRange problem. */ import acm.program.*; i public class FindRange extends ConsoleProgram { p private static final int SENTINEL=0; p public void run() { p println("This program finds the largest and smallest numbers.");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: print("? "); int x=readInt(); i if(x==SENTINEL) {println("No values have been entered.");return;} int smallest=x; int largest=x; while(x!=SENTINEL){ if(x>largest) largest=x; if(x<smallest) smallest=x; print("? "); x=readInt(); } println("smallest: "+smallest); println("largest: "+largest); } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online