1 00:00:05,320 --> 00:00:08,460 All right, congratulations for making it through this section. 2 00:00:09,210 --> 00:00:11,069 We covered a lot of material in this section. 3 00:00:11,389 --> 00:00:13,560 Hopefully, you have a pretty good grasp of c++ 4 00:00:13,639 --> 00:00:14,969 functions and how they work. 5 00:00:15,920 --> 00:00:17,260 Now you're ready for a challenge. 6 00:00:17,660 --> 00:00:19,010 This challenge won't be easy. 7 00:00:19,180 --> 00:00:20,990 Remember the challenge from section 9. 8 00:00:21,290 --> 00:00:24,450 In that challenge, we had a vector of integers and we wrote a menu-driven 9 00:00:24,450 --> 00:00:27,730 system that allowed the user to display the numbers, add a number 10 00:00:27,730 --> 00:00:30,419 to the list, calculate the mean, the smallest and the largest. 11 00:00:31,059 --> 00:00:33,310 That challenge was all about applying what you learned up to 12 00:00:33,310 --> 00:00:36,640 that point in the course, and let you use control flow statements 13 00:00:36,640 --> 00:00:38,240 like loops and if statements. 14 00:00:38,780 --> 00:00:41,890 Well, for this challenge, we're going to solve that problem all over again. 15 00:00:42,250 --> 00:00:45,920 Except this time our solution will be modularized in terms of functions. 16 00:00:46,639 --> 00:00:50,209 You can start with your solution and refactor it so that it uses functions. 17 00:00:50,410 --> 00:00:52,859 Or you can start with my solution which is included in the 18 00:00:52,869 --> 00:00:55,410 challenge project in workspace 11. 19 00:00:55,650 --> 00:00:58,430 Or you could start this challenge from scratch, it's really up to you. 20 00:00:59,340 --> 00:01:01,590 Let me give you a few hints and tips for this challenge. 21 00:01:02,000 --> 00:01:05,089 Remember, this is not an easy challenge, so if you get frustrated 22 00:01:05,090 --> 00:01:06,860 take a break, come back to it later. 23 00:01:07,530 --> 00:01:08,429 Here are a few hints. 24 00:01:09,020 --> 00:01:12,210 Create functions for each of the major functions in the program. 25 00:01:13,400 --> 00:01:14,910 Keep the function small. 26 00:01:15,180 --> 00:01:17,160 Remember the boss worker analogy. 27 00:01:18,050 --> 00:01:20,779 Keep the vector declaration in the main function and 28 00:01:20,780 --> 00:01:23,600 pass the vector object to any function that requires it. 29 00:01:24,509 --> 00:01:27,849 Don't be tempted to move that vector object outside the main 30 00:01:27,849 --> 00:01:30,580 and make it a global variable that will really defeat the 31 00:01:30,580 --> 00:01:32,160 whole purpose of this exercise. 32 00:01:33,310 --> 00:01:36,170 Now you can start by defining a function that displays the menu, 33 00:01:36,170 --> 00:01:39,350 that's a real simple function call it display menu, and all it is 34 00:01:39,350 --> 00:01:40,940 is a bunch of output statements. 35 00:01:41,210 --> 00:01:44,070 And then you can call that function whenever you need to display the menu. 36 00:01:44,830 --> 00:01:47,609 You can then define a function that reads the selection from the 37 00:01:47,609 --> 00:01:49,840 user and returns it in uppercase. 38 00:01:50,540 --> 00:01:52,420 That way we don't have to deal with checking lowercase 39 00:01:52,420 --> 00:01:53,872 and uppercase selections. 40 00:01:53,872 --> 00:01:56,127 Then create functions for each menu option. 41 00:01:56,127 --> 00:01:59,672 And then finally, create functions that display the list of numbers, 42 00:01:59,672 --> 00:02:03,217 function that calculates the mean a, function that looks for the 43 00:02:03,217 --> 00:02:05,473 smallest and the largest and so forth. 44 00:02:05,473 --> 00:02:08,910 Take it one function at a time, and take your time. 45 00:02:09,550 --> 00:02:11,680 Again, if you get frustrated, take a break. 46 00:02:12,430 --> 00:02:15,240 Finally, don't forget to use function prototypes. 47 00:02:15,750 --> 00:02:18,800 Use them, let the compiler help you every step of the way. 48 00:02:19,590 --> 00:02:20,479 All right, good luck. 49 00:02:20,599 --> 00:02:21,470 I know you can do it. 50 00:02:21,580 --> 00:02:25,110 When you're finished, compare it to my solution, which is in the next video.