Help With empty value in array elements.

Hi all,

I'm trying to write a program that lets the user to input the salaries of 10 employees into an array, then the program will do an error check to see which of the employee's salary information has "not been entered", which means, if zero is entered, it's still counts as an input and the information is stored.

eg)
Employee ID#:_______Salary amount $:
1____________________2000
2____________________3000
3____________________5000
4 ____________________4000
5 ____________________ -
6 _____________________0
7 ___________________1500
8 ______________ ______-
9 ___________________2500
10____________ ______ 500

Note: that employee "5" and "8" does not have any data input to them, while employee "6" has zero salary.

The problem for me is that, array elements are automatically assigned to zero if no values are inputted to that element. I planned to utilize the zeros to flag for the errors...but apparently, a user can input zero as the salary.

I would appreciate it very much if someone could give me a "hint" on how to flag for the empty inputs.


Last edited on
closed account (48T7M4Gy)
Hint: Have a parallel array that indicates data has been input. Initalize the parallel array to zero or bool false ... update as input is inserted to data array and use as a flag on output.

A struct/class is a more sophisticated encapsulation doing the same. Now have 3 choices. :)

PS and yet another option. Defaulted string array then convert to numeric as required.

PPS maybe somebody has an idea on null values ???
Last edited on
omg...i've completely forgot about parallel arrays!

i've spent almost an hour thinking how to flag this....and you solved it in a few seconds. LOL, i love the community here!

struct is too high tech for me lol, so ill pass that, and string to int is too much work for the entire program with compounding interest rate calculations.

Ty very much for the help!
closed account (48T7M4Gy)
I wouldn't use strings either. Cheers
Topic archived. No new replies allowed.