Hello, my professor gave us a file that has peoples names, current salary, and salary % increase. He is wanting us to code a program that will read the data from a file then display it onto the screen in organized columns. However, he also wants us to calculate what the new salary will be using the % increase and current salary. I have the program to where it will display everything properly, however I have know idea how to make the computer grab the correct values as variables to calculate the new salary. Please help
You know the order of the data in the file. Read in each piece of data one at a time. You know which read is the salary. Read it in to a number type, such as int. You know which read is the percentage. Read it in to a number type. Use cin to do this. Calculate the new salary from those two data.
Hmm, well it should be entering the while loop at least once before it fails. Do you have a print statement inside your while loop to check of it's entering there? (You can also use a proper debugger, but print statement's are a poor man's debugger).
If your file has the percent sign % after at the end of the 4th number, you'll need to loop through a fifth token to capture that.
Okay, i've got it to where it will display the data I need, however I need it to be in perfect columns, how can i get it organized? As you can see i tried using spaces but it doesn't work
If needed, there is other formatting functionality in the <ios> header, namely std::left and std::right http://en.cppreference.com/w/cpp/io/manip/left (if you need the correct justification).
setw will automatically add more whitespace (by default) to match the width you need.
Ex, this will give yourself 10 characters of room for the first name, and 20 characters of space for the last name.