CIS 150 Lab: Repetition

Objectives

  • Create a do-while loop that outputs specific values
  • Create a while loop that outputs specific values
  • Create a for loop that outputs specific values
  • Create a loop that performs input validation
  • Create a loop that displays a nicely formatted table of values

Lab requirements

Modify the supplied program (repetitionLab.cpp) to make it work properly.

Example run of program

Part I (while loop) The square root of 10 is 3.16228 The square root of 11 is 3.31662 The square root of 12 is 3.4641 The square root of 13 is 3.60555 The square root of 14 is 3.74166 The square root of 15 is 3.87298 The square root of 16 is 4 The square root of 17 is 4.12311 The square root of 18 is 4.24264 The square root of 19 is 4.3589 The square root of 20 is 4.47214 Part II (do-while loop) The square root of 10 is 3.16228 The square root of 11 is 3.31662 The square root of 12 is 3.4641 The square root of 13 is 3.60555 The square root of 14 is 3.74166 The square root of 15 is 3.87298 The square root of 16 is 4 The square root of 17 is 4.12311 The square root of 18 is 4.24264 The square root of 19 is 4.3589 The square root of 20 is 4.47214 Part III (for loop) The square root of 10 is 3.16228 The square root of 11 is 3.31662 The square root of 12 is 3.4641 The square root of 13 is 3.60555 The square root of 14 is 3.74166 The square root of 15 is 3.87298 The square root of 16 is 4 The square root of 17 is 4.12311 The square root of 18 is 4.24264 The square root of 19 is 4.3589 The square root of 20 is 4.47214 Part IV (input validation) Enter a number between 1 and 100: -4 Enter a number between 1 and 100: 200 Enter a number between 1 and 100: 53 Part V (40 column table) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 Press enter to continue...

Rubric

  • 2 points: for getting part 1 working properly
  • 2 points: for getting part 2 working properly
  • 2 points: for getting part 3 working properly
  • 2 points: for getting part 4 working properly
  • 2 points: for getting part 5 working properly