Section 1: The Basics
Here we're going to go over the basic components of really any programming language. I'm going to assume that you've already been exposed to these concepts before, so most of this might be a refresher. However, that doesn't make this section any less important to go over. Having a strong grasp on the basic tools of programming is absolutely required, as everything beyond this builds upon these concepts and tools. If you don't know how to use your tools well, then you can't use them to their full potential.
Below are some sites that I think explain these key topics well. Since this should just be a review, reading them may not be necessary, but if you find yourself getting stuck on the practice problem below, step back from it, and give these a read. While it's critical to understand these concepts, it's also important to know you have the internet at your fingertips, so don't be afraid to look stuff up when you get stuck! The key to growth in this field, especially when starting out, is to constantly be learning, recognizing when you don't fully understand something, and seek out the answers to remove that confusion and deepen your understanding of these concepts.
Do be aware that the links provided are just the bare minimum as to the different topics could cover. There's other variations and keywords that I won't go into explicit detail here, but the links will provide you with a starting point. From there, explore around and learn more about the topics!
Practice Problem
Since this is our first practice problem, I'll explain how this works. To go along with the readings provided above, there will be a practice problem to go along with it. This problem should utilize the concepts discussed above in some fashion. The problem will detail out exactly what should be expected, with some sample output to give an idea as to what I'm looking for. You won't be provided ANY starting code, as I feel part of the learning process is how you design your program, rather than just filling in the blanks. How you end up designing the program is totally up to you, as long as you're utilizing the concepts above and it behaves similar to way described below.
I'll also be providing a link to a GitHub repo with my solution to the problem. I highly recommend not looking at it until your satisfied with your program. If you get stuck, don't look at my answer, but review the concepts above and ask the internet for help! Utilize all your tools, just like how you would in a real-world environment.
Without further ado, let's get into the problem!
Array Manipulation
This is a problem that I would ask students I was tutoring back in college, it was a good assessment as to gauging how well they understood these concepts. I will be adding on some additional components to it, as we're no longer bound by the time-constraints of college. What we're going to build is a simple menu-driven, command line based program that will allow users to manipulate an array and display information about it. We'll be working with doubles for our underlying data.
For the menu, you'll provide the following options for the user:
- Add a new number to the array.
- Search the array for a specified number and inform the user of the result.
- Remove all instances of a specified number from the array.
- Sort the array from lowest to highest.
- Print out the entire array.
- Print out the number at the specified index of the array.
- Print some statistics of the array. The Mean, Median, and Mode.
- Clear the array.
- Exit the program.
That's it! It's a pretty straight forward program, but it could get a bit messy if you don't design it well. So here's some pointers to try to follow while you program this:
- Try to avoid duplicate code. You might find some of the options will require similar processes to achieve. Try to utilize methods/functions to wrap up the code to utilize in multiple areas.
- Be careful with user input! The user isn't guaranteed to enter valid data, so be sure to check if their input is one of the nine options, or even is a number to begin with!
- Also be aware of various edge cases you could get into. What if you have no values in your array? What if you try to add a value when your array is full? These cases may not be obvious initially, but just be aware of them and try to identify them as your implement each option.
- The sample output can be found here.
Once you're done with the project, you can check your answer with my solution on Github. If you feel like you're comfortable with these concepts, let's move on to Section #2!