Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TwoSmallest
- {
- public static void main(String[] args)
- {
- System.out.println("Enter terminating number:");
- double term = IO.readDouble();
- double num;
- double smallnum = IO.readDouble();
- double secondsmallnum = IO.readDouble();
- do
- {
- if (secondsmallnum <= smallnum)
- {
- double a = smallnum;
- smallnum = secondsmallnum;
- secondsmallnum = a;
- }
- num = IO.readDouble();
- if(num <= smallnum)
- {
- secondsmallnum = smallnum;
- smallnum = num;
- }
- else if (num >= smallnum && num <= secondsmallnum)
- {
- secondsmallnum = num;
- }
- } while(num != term);
- IO.outputDoubleAnswer(smallnum);
- IO.outputDoubleAnswer(secondsmallnum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement