You haven't stated what defines a valid/invalid value.
In fact, the problem statement is a bit self-inconsistant in that the array is stated as containing "valid sales values", but you are instructed to use only the valid values of the array in the calculations.
If you know what the characteristic of an valid or invalid value is, then you can check for it inside the
for
loop:
for (int k = 0; k < salesAmount.Length; k++)
{
decimal amount = salesAmount[k];
if ()
{
if (amount < lowest)
{
lowest = amount;
}
if (amount > highest)
{
highest = amount;
}
totalSalesAmount += amount;
}
}
It seems unusual to provide the count of invalid values if you are expecte to determine which are valid yourself. There seems no point in providing that value, as you can determine it yourself in the loop.