Hello, I am a programming student and I'm glad I found this board. I have a problem I could use some help with.
The program should calculate an employees raise based on which department they work in. When I run the program, it calculates and displays two different raise amounts, one for department A and B(which have the same raise amount), and another for department C. I do not want both amounts to display.
Also, when the program executes, I need to have a data validation step. The program will display the message that states "Please enter A, B, or C" even if the user enters A, B or C. It also continues to execute if the input is not correct.
That was huge help!
It no longer displays both calculations.
Thanks to both of you.
What about the data validation? The program still executes with invalid input.
If you want the user to keep re-entering until they're input is equal to A,a,B,b,C or c. You're gonna have to use a loop, a while-loop specifically in this case. See if you can handle it by yourself -
Why don't you convert the user input to all capital letter instead of having different conditions, e.g 'a', 'A', 'b''B'.
That way, there will be only one option which is capital letter and that will make the conditions look better.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/* toupper example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
int i=0;
char str[]="Test String.\n";
char c;
while (str[i])
{
c=str[i];
putchar (toupper(c));
i++;
}
return 0;
}