Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public class TwoSmallest {
  2.  
  3. /**
  4. * @param args
  5. */
  6. public static void main(String[] args) {
  7. // TODO Auto-generated method stub
  8.  
  9. System.out.println("Terminating value?");
  10. double tValue = IO.readDouble();
  11. double smallest = 0;
  12. double smallest2 = 0;
  13. double x = 0;
  14. int numx = 0;
  15. System.out.println("Enter first number");
  16. x = IO.readDouble();
  17. smallest = x;
  18. smallest2 = x;
  19. while (x != tValue)
  20. {
  21. System.out.println("Enter numbers");
  22. x = IO.readDouble();
  23. if (x < smallest)
  24. {
  25. smallest2 = smallest;
  26. smallest = x;
  27. }
  28. else if (x < smallest2)
  29. {
  30. smallest2 = x;
  31. }
  32. }
  33. IO.outputDoubleAnswer(smallest);
  34. IO.outputDoubleAnswer(smallest2);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement