case and function problem

My assignment is to work with a phone number input using 3 functions besides the main function. When setting a character input, when lowercase, to toupper, how can that letter stay toupper when transferring it to the next function? Here is my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
char AcknowledgeCall(char call)
{
	cout << "You entered: " << call << endl;
	return call;
}

char ToDigit(char ch)
{
	if (islower(ch))
	{
		static_cast<char>(toupper(ch));
	}

	AcknowledgeCall(ch);

	return ch; // if digit is valid
}


Also in the ToDigit function a switch should be used to determine if the digit is valid (a-z or 0-9) and convert letters to digits, but I though switches were mostly used for showing the user a message based on their input. Like if 1-3
1
2
3
4
5
6
7
8
9
10
11
12
switch (number)
{
   case 1:
     cout << "Good job" << endl;
     break;
   case 2:
     cout << "Horrible" << endl;
     break;
   case 3:
     cout << "You lose" << endl;
     break;
}


Last edited on
1:

 
		ch = static_cast<char>(toupper(ch));


2:
Actually, I never (which means: rarely) use switches for user output. Though that's of course what switches are usually being used for in beginner examples.
I've not seen a whole lot on switches being used, but the assignment asks for them.
Topic archived. No new replies allowed.