Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public class TwoSmallest
  2. {
  3. public static void main(String[] args)
  4. {
  5. System.out.println("Enter terminating number:");
  6. double term = IO.readDouble();
  7. double num;
  8. double smallnum = IO.readDouble();
  9. double secondsmallnum = IO.readDouble();
  10. do
  11. {
  12. if (secondsmallnum <= smallnum)
  13. {
  14. double a = smallnum;
  15. smallnum = secondsmallnum;
  16. secondsmallnum = a;
  17. }
  18. num = IO.readDouble();
  19. if(num <= smallnum)
  20. {
  21. secondsmallnum = smallnum;
  22. smallnum = num;
  23. }
  24. else if (num >= smallnum && num <= secondsmallnum)
  25. {
  26. secondsmallnum = num;
  27. }
  28.  
  29. } while(num != term);
  30. IO.outputDoubleAnswer(smallnum);
  31. IO.outputDoubleAnswer(secondsmallnum);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement