CS 1160 C/C++ Programming 12 MWF - Spring 2016

March 7th thru March 11th - Week #9


Monday 03/07/2016


  1. Test One handed back: Test One Scores...


Wednesday 3/09/2016


  1. How to check for errors in input:
         cout << "Please enter a positive integer: ";
         cin >> theNumber;
    
         while (theNumber <= 0)
         {
            cout << "It must be a positive integer!  Try again:  ";
            cin >> theNumber;
         }
    
    
  2. The binary search algorithm was handed out in a previous class. We covered the binary search algorithm in depth, including the HI LO guessing game where you attempt to guess a number between 1 and 1000. It only takes 10 guesses maximum if you use the binary search idea and are told if your guess was too low or was too high when you are wrong.

  3. ...


Friday 3/11/2016


  1. A simulation program was developed that generated a random set of numbers representing the birthday of 23 different persons.

    The random numbers were between 1 and 365 inclusive. Thus 33 would be Ground Hog's Day (Feb 2nd) and 364 would be December 30th or New Year's Eve Eve.

  2. Output of 23 birthdays - a set of 23 Julian dates, i.e. days of the year. Beginning version showing the contents of the sorted array.
    [jacobson@weblab cpp]$ ./a.out
    
      5  33  80  80  92 127 134 145 150 162 176 182
    183 185 190 197 218 224 227 235 259 280 339
    
    Group had repeat birthday
    

  3. Selection sort and arrays: 23birthdays.cpp... Beginning version that runs simulation ONCE.

  4. Nested loops, arrays, selection sort: How many of 1000 groups would have at least one repeat birthday, or with 23 persons present, would have 22 or fewer different birthday days?

  5. Sample output: Running the C++ simulation program several times. Is it about 50% of the time????