
Your code presents a prompt (a list of values) and then asks the user to pick one. In a number of places in your code, you have something like a menu. Use a menu object or at least a common menu function That way it's much more clear that they are related and helps in both maintenance and understanding of the code. Consider instead defining an object to contain both a color name and the associated value. The color strings and the values they represent are tightly bound but not in your data structures. Then rewrite the contents of those functions to do what you want using C++. First, isolate these into a seperate functions cls() and pause() and then modify your code to call those functions instead of system. Specifically, if some program is defined and named cls or pause, your program will execute that program instead of what you intend, and that other program could be anything. The second is that it's a security hole, which you absolutely must care about. The first is that it is not portable to other operating systems which you may or may not care about now. There are two reasons not to use system("cls") or system("pause"). It's not necessarily wrong to use it, but you should be aware of when not to (as when writing code that will be in a header). Putting using namespace std at the top of every program is a bad habit that you'd do well to avoid. I have found a couple of things that could help you improve your code. Loop to take care of the case of letters


Loop to show each color and the number it corresponds to Int a, b, c // Holds the 3 colors from band which are entered by userĭouble product // Stores result from calculation Int tolerance(string, double, const int) Ĭonst int band = 10, multiplier = 12, toleranceSize = 4 // Represents size of each string array #include ĭouble time(string, double, const int, int, int, int) My professor has given me the liberty to use either 1 or 2 dimensional arrays. The picture above shows the colors and the data values associated with each.

I have completed my source code for this program and it runs perfectly, but I would like some feedback on how to improve this code before I submit it. The purpose of this program is to write a code that will give a user a list or menu of choices that show colors and their values according to some data and prompt them to enter input to determine the value of a resistor.
