I am back this week with another homework problem. My array is not working like I thought it would. My brain is about to explode trying to comprehend what is going on. This code will compile but, it won't do what I want it to. The array is supposed to have columns of employee numbers and rows of product numbers. Then you can input an employee number and product number and add to that total for a given number of days. For some reason my for statement for the number of days is not working. And the employee number and product numbers are not going where I think they should be. The total code at the bottom is a little sloppy and I can fix that once I can get the array problem figured out. Any help would be greatly appreciated.
In the statements "if(productnumber=0)" , i suppose you must have got a warning as i did. the test expression for the if statement is supposed to be a logical expression evaluating to true or false and not an assignment statement. i guess you meaned to write
"if(productnumber==0)" with 2 equal to signs.
sales[4][productNumber-1] += productTotal;
The above statement has been used once in each case of the switch statement with the switch variable "employeeNumber" and the only thing i noticed different in each case was in the idices of the 2d array sales. i guess this is what you must have meant
i didnt have time to go in to the logic of the program in too much detail but maybe sometimes correcting these if possible and reducing the number of switch statements to just a single line may help reduce the complexity and the size of the program to a large extent.
well , you could have just said "employeenumber-1" in the first index of the array, as that is the only thing i can see as the difference in the diff cases.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.