brainfrz

Untitled

Sep 23rd, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. Title: Lab 5
  2. Author: Terry Weiss
  3. Date: 9/29/15
  4. Course & Section: CSC 109-103W
  5. Description: This program will will prompt the user for three numbers and displays them in ascending order.
  6.  
  7. Initial Algorithm
  8. Get 3 numbers
  9. Add the smallest number to a list
  10. Add the second smallest number to a list
  11. Add the remaining number to a list
  12. Display the list in ascending order
  13.  
  14. Data Requirements:
  15. (int) number1 – This is the first number given by the user.
  16. (int) number2 – This is the second number given by the user.
  17. (int) number3 – This is the third number given by the user.
  18. (int[]) list – This is the list of numbers in ascending order.
  19. (Scanner) user_input – This is the object that holds the user’s input.
  20.  
  21. Formulas: None
  22.  
  23. Refined Algorithm
  24. Get 3 numbers
  25. IF number1 < number2 AND number1 < number3 THEN
  26. Put number1 first in list
  27. IF number2 < number3 THEN
  28. Put number2 second in list
  29. Put number3 third in list
  30. ELSE
  31. Put number3 second in list
  32. Put number2 third in list
  33. END IF
  34. ELSE IF number2 < number1 AND number2 < number3 THEN
  35. Put number2 first in list
  36. IF number1 < number3 THEN
  37. Put number1 second in list
  38. Put number3 third in list
  39. ELSE
  40. Put number3 second in list
  41. Put number1 third in list
  42. END IF
  43. ELSE
  44. Put number3 first in list
  45. IF number1 < number2 THEN
  46. Put number1 second in list
  47. Put number2 third in list
  48. ELSE
  49. Put number2 second in list
  50. Put number1 third in list
  51. END IF
  52. END IF
  53. Display numbers from list in ascending order
Advertisement
Add Comment
Please, Sign In to add comment