I'm having a hard time understand this problem. I know that we have to use a switch statement and the program has to hold count the number of times each character was entered. But I need some help. If anyone could assist me that would be great.
What exactly do you need help with? It sounds pretty straight forward to me.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
while(letter != '.')
{
switch(letter)
{
case'R':
//increment count for retired
break;
...
case'A':
//increment count for active <--this has extra feature also
//ask for the number of years since employed
break;
default:
//catch any erroneous values here
}
}
//display table
You have created an infinite loop, therefore the boolean expression in your while loop will always be true. You should also look at variable initializations.
Just looking at your variable's initial values, none of them are reset to zero. Either make them global outside of main so that the compiler will zero them or set each one to zero when you declare them.
1 2 3 4 5 6 7
int main()
{
char status = 0;
int retire = 0;
int active = 0;
...
Well I did what you said venomDev but the program still won't let me enter a letter. I try to input "R" but when I press enter nothing happened. Still don't know what I'm doing wrong
You still provide no way to break out of the loop. There is no way for the condition to change once the loop starts. It would be better to use a do/while loop, but as it stands you need to ask again for the status after the switch. Also you need to take input from the default part of the switch.