TwoSmall

TwoSmall - } number3 = IO.readInt(); while (number3 != -1)...

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

View Full Document Right Arrow Icon
public class TwoSmall { public static void main(String[] args) { int number1, number2, number3, small, secsmall; i number1 = IO.readInt(); secsmall = 0; small = 0; if (number1 < 0) { IO.reportBadInput(); return; } number2 = IO.readInt(); if (number2 < 0) { IO.reportBadInput(); return; } if (number1 >= number2) { secsmall = number1; small = number2; } else { small = number1; secsmall = number2;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } number3 = IO.readInt(); while (number3 != -1) { if (secsmall > number3 && small < number3) { secsmall = number3; } else if (secsmall > number3 && small > number3) { secsmall = small; small = number3; } else { secsmall = secsmall; small = small; } number3 = IO.readInt(); } IO.outputIntAnswer(small); IO.outputIntAnswer(secsmall); } }...
View Full Document

This note was uploaded on 07/12/2009 for the course CS 111 taught by Professor Hari during the Fall '08 term at Rutgers.

Ask a homework question - tutors are online