Hello, I am working on a C# GUI in Visual Studio to write a program named ChatAWhile that allows a user to enter an area code and the length of time for a call in minutes, and then display the total cost of the call.
The area codes given are 262, 414, 608, 715, 815, 920.
The Per Minute Rates are 0.07, 0.10, 0.05, 0.16, 0.24, 0.14.
here is the code I have thus far....
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[] areaCode = new int[] { 262, 414, 608, 715, 815, 920 };
double[] perMinuteRate = new double[] { 0.07, 0.10, 0.05, 0.16, 0.24, 0.14 };
int validAreaCode;
double totalCharge;
double inputLength;
//double areaCodeperMinuteRate = 0;
validAreaCode = Convert.ToInt32(areaCode1.Text);
inputLength = Convert.ToDouble(callLength.Text);
for (int x = 0; x <= areaCode.Length; ++x)
{
totalCharge = perMinuteRate[x] * inputLength;
Result.Text = String.Format("The area code is {0} and the cost of the call is {1}.", validAreaCode, totalCharge);
}
}
}
I know I am missing one thing! It displays exactly what I want it to, EXCEPT I think the equation is wrong because it is always multiplying zero instead of connecting to the second array. But I get an error message when I put in the perMinuteRate array instead of areaCodePerMinuteRate because you can't multiply an array and a double. Anyone have any hints or suggestions to help with what I should do??