Is anybody capable of providing me with guidance, not opinions?
So the question is:
People sometimes give their telephone number using one or more alphabetic characters. Write a program that accepts a 10-digit telephone number that may contain one or more alphabetic characters. Display the corresponding number using numerals. The numbers and letters are associated as follows on your telephone:
ABC:2
DEF:3
GHI:4
JKL:5
MNO:6
PQRS:7
TUV:8
WXYZ:9
If the user enters a character that is not on the telephone as part of the number, display a message indicating that the value does not match a number. Allow both upper- and lowercase characters to be entered.
This must also be created for use in a Windows Form Application, by the way..
Now, I've been attempting to complete this assignment for the past week. I have tried if statements, for/foreach loops, etc. and I still am unable to finish it properly.
Here is what I currently have:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Collections; //The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hashtables and dictionaries.
namespace CellNumber_Converter
{
public partial class Form1 : Form
{
private Hashtable htPhoneNumbers = new Hashtable(); //hashtable to store keys + numbers
private string strNumber;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
strNumber = textBox1.Text.ToUpper(); //convert entered text to uppercase
foreach (char c in strNumber) //Loop through entered text
{
string digit = c.ToString(); //Convert to string
if (htPhoneNumbers.ContainsKey(digit)) //if Entered text is any of the keys
{
label1.Text += htPhoneNumbers[digit]; //add to label
}
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
htPhoneNumbers["A"] = "2"; //Store the word "2" inside the hashtable at location "A" etc.
htPhoneNumbers["B"] = "2";
htPhoneNumbers["C"] = "2";
htPhoneNumbers["D"] = "3";
htPhoneNumbers["E"] = "3";
htPhoneNumbers["F"] = "3";
htPhoneNumbers["G"] = "4";
htPhoneNumbers["H"] = "4";
htPhoneNumbers["I"] = "4";
htPhoneNumbers["J"] = "5";
htPhoneNumbers["K"] = "5";
htPhoneNumbers["L"] = "5";
htPhoneNumbers["M"] = "6";
htPhoneNumbers["N"] = "6";
htPhoneNumbers["O"] = "6";
htPhoneNumbers["P"] = "7";
htPhoneNumbers["Q"] = "7";
htPhoneNumbers["R"] = "7";
htPhoneNumbers["S"] = "7";
htPhoneNumbers["T"] = "8";
htPhoneNumbers["U"] = "8";
htPhoneNumbers["V"] = "8";
htPhoneNumbers["W"] = "9";
htPhoneNumbers["X"] = "9";
htPhoneNumbers["Y"] = "9";
htPhoneNumbers["Z"] = "9";
}
}
}
Fourth, have a lookm at the attachment.
Fifth, Read the abovementioned article properly, else, this post helps you nothing - yes, it gives you the answer, but you will not learn anything from it if you don't do some research...
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.