31
Answers

Parallel array

Maha

Maha

12y
3.6k
1
This program is for question 4. When the area code is 262 program is executing well but program is not working for other area codes. Please correct the error. I attach the question.

using System;

namespace _6e4
{
class Program
{
static void Main(string[] args)
{
int[] code = {262, 414, 608, 715, 815, 920};
double[] rate = {0.07, 0.10, 0.05, 0.16, 0.24, 0.14};
double cost;

Console.Write("Enter the area code ");
string s = Console.ReadLine();

Console.Write("Number of minutes talk ");
string t = Console.ReadLine();

for (int x = 0; x < code.Length; ++x)
{
if(Convert.ToInt32(s)==code[x])
{
cost = rate[x] * Convert.ToDouble(t);
Console.WriteLine("Total cost = {0}", cost.ToString("C"));
x = code.Length;
}
Console.ReadKey();
}
}
}
}


Attachment: 228.zip

Answers (31)