Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.07 KB | None | 0 0
  1. public class Modular_Decomposition
  2.  
  3. {
  4.  
  5. /*Established the main class as type void. Then initializes variable hour of integer type to 0, variable hoursPerDay also of integer type to 24,
  6. also initializes the variable name hoursPerHalfDay with the value of 12 in integer data type. Then, I started a while loop that runs as long
  7. as the hour is less than the number of hours per day (24). Each time the loop runs the value of hour is incremented up one, the method printHour,
  8. Report, Checkpoint, Extract, and Upload are called. Lastly, a new line is printed using System.out.print and the new line key "\n".
  9. */
  10.  
  11. public static void main(String[] args)
  12. {
  13.  
  14. int hour = 0;
  15. int hoursPerDay = 24;
  16. int hoursPerHalfDay = 12;
  17.  
  18. while(hour < hoursPerDay)
  19. {
  20.  
  21. hour++;
  22. printHour(hour, hoursPerHalfDay, hoursPerDay);
  23. Report(hour);
  24. Checkpoint(hour);
  25. Extract(hour);
  26. Upload(hour);
  27. System.out.print("\n");
  28.  
  29. }
  30. }
  31.  
  32.  
  33.  
  34. /* **The printHour method** The variables hour, hoursPerHalfDay, and hoursPerDay are called in the method header. I then created an if statement
  35. that will run only if the value of hour is less than the value of hoursPerHalfDay. In this if statement the value of hour is concatenated with
  36. the string " AM", and then ended. Then, there is an else if statement that only occurs when the value of hour is equal to the value of hoursPerHalfDay.
  37. When this condition is met, the value of hour is concatenated with the string " PM". Then another else if is made. This time the condition is
  38. when both hour is greater than hoursPerHalfDay (12) and less than hoursPerDay (24). When these two things occur, the value of hour minus 12 is
  39. concatenated with the string " PM". Then the last else if condition is made. The condition for this one is when the value of hour equals hoursPerDay.
  40. When this condition is met, the value of hour minus 12 is concatenated with the sting " AM".
  41. */
  42.  
  43. public static void printHour(int hour, int hoursPerHalfDay, int hoursPerDay)
  44. {
  45.  
  46. if(hour < hoursPerHalfDay)
  47. {
  48.  
  49. System.out.print(hour + " AM");
  50.  
  51. }
  52.  
  53. else if(hour == hoursPerHalfDay)
  54. {
  55.  
  56. System.out.print(hour + " PM");
  57.  
  58. }
  59.  
  60. else if(hour > hoursPerHalfDay && hour < hoursPerDay)
  61. {
  62.  
  63. System.out.print((hour - 12) + " PM");
  64.  
  65. }
  66.  
  67. else if(hour == hoursPerDay)
  68. {
  69.  
  70. System.out.print((hour - 12) + " AM");
  71.  
  72. }
  73.  
  74. }
  75.  
  76. /* ***The Report Method*** The variable hour is called in this method. Then, an if statement is created with the condition being if hour equals 8, 12,
  77. or 18 then "tab tab Report tab |" will be printed. If this condition is not met, the catch all "else" will print out tab tab tab tab | to keep the
  78. correct alignment.*/
  79.  
  80. public static void Report(int hour)
  81. {
  82.  
  83. if(hour == 8 || hour == 12 || hour == 18)
  84. {
  85.  
  86. System.out.print("\t \t Report \t |");
  87.  
  88. }
  89.  
  90. else
  91. {
  92.  
  93. System.out.print("\t \t \t \t |");
  94.  
  95. }
  96.  
  97. }
  98.  
  99. /* ***The Checkpoint Method*** The variable hour is called in this method. Then, an if statement is created with the condition being that
  100. hour equals 4, 8, 12, 16, 20, or 24. If this condition is met, "tab Checkpoint tab |" will be printed. If the condition is not met else it will
  101. fall under else and "tab tab tab |" will be printed.*/
  102.  
  103. public static void Checkpoint(int hour)
  104. {
  105.  
  106. if(hour == 4 || hour == 8 || hour == 12 || hour == 16 ||
  107. hour == 20 || hour == 24)
  108. {
  109.  
  110. System.out.print("\t Checkpoint \t |");
  111.  
  112. }
  113.  
  114. else
  115. {
  116.  
  117. System.out.print("\t \t \t |");
  118.  
  119. }
  120.  
  121. }
  122.  
  123. /* ***The Extract Method*** The variable hour is called in this method. Then, an if statement is created with the condition of hour being
  124. equal to 8 or 21. When this condition is met, "tab Extract tab |" is printed. If this condition is not met, "tab tab tab 1\" is printed.
  125. */
  126.  
  127. public static void Extract(int hour)
  128. {
  129.  
  130. if(hour == 8 || hour == 21)
  131. {
  132.  
  133. System.out.print("\t Extract \t |");
  134.  
  135. }
  136.  
  137. else
  138. {
  139.  
  140. System.out.print("\t \t \t |");
  141.  
  142. }
  143.  
  144. }
  145.  
  146. /* ***The Upload Method*** The variable hour is called in this method. Then, an if statement is created with the condition of hour being
  147. equal to 11 or 20. If this condtion is met "tab Upload tab|" is printed. If the condition is not met "tab tab tab |" is printed.
  148. */
  149.  
  150. public static void Upload(int hour)
  151. {
  152.  
  153. if(hour == 11 || hour == 20)
  154. {
  155.  
  156. System.out.print("\t Upload \t |");
  157.  
  158. }
  159.  
  160. else
  161. {
  162.  
  163. System.out.print("\t \t \t |");
  164.  
  165. }
  166.  
  167. }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement