So for this C# class I have to have the user input a 7 digit phone number into the console. Each number is stored as a different character. Then each character is changed to a letter. There is no logic behind the letters the numbers are changed to. (I really don't see the point of this assignment, which might be contributing to my coder's block.) Here's what the assignment says.
Your mission: A prepaid phone service needs a program that converts alphanumeric keyboard input into a phone number. The user will input eight characters and the program will output either an error message or the translated seven-digit phone number. The input may contain digits, letters, or both. Letters can be uppercase or lowercase.
Method of Coding:
- Main(): Declares seven character variables and passes these to the following methods by reference:
- ProcessInput(): gets user input and performs the conversion
- ShowResults(): displays the results
- GetInput(): Gets seven characters from the user and stores them into the seven variables Main() has passed by reference.
- ProcessInput(): Calls ToDigit() for each, passing each character variable by reference, and returns one of these codes to Main() by value: o 0 if there were no input errors o -1 if there were input errors"
- ShowResults(): displays the results
- ProcessInput(): gets user input and performs the conversion
The program will perform the conversion per a standard telephone keypad layout.
Basically, 2 s A,B,C 3 is D,E,F Etc and then D, E, F is 3 and so on.
Right now I have nothing done except for an input, but it's not stored as characters, just a string. I really hate this assignment because we just did two assignments with Cases and If statements, it just seems redundant to me.
Console.WriteLine("Write a Phone Number that consists of Seven Numbers.");
string Number = Console.ReadLine();
if (Number.Length != 7)
Console.WriteLine("You have entered a phone number that is too long.");
Console.WriteLine("You have entered: {0}", Number);
Console.ReadLine();
So my real question is: How do I store the input number as a character and then define those characters with case statements?