Instructions ChatAWhile.cs using static systen.console; The Chat-A-While phone c
ID: 3756328 • Letter: I
Question
Instructions ChatAWhile.cs using static systen.console; The Chat-A-While phone company provides service to six area codes and charges the per-minute rates for phone calls shown in Figure 6-25 (below). 2 using static Systen.Console; 3 class ChatAWhile 4 static void Main() 7 // Write your main here Write a program named ChatAWhile that stores the area codes and rates in parallel arrays and 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. For example if the area code is in the array, such as 715, and the call length is 22 minutes, the output should be:Explanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class ChatAWhile
{
public static void Main(string[] args)
{
string[] area_code = {"101" , "102" , "103" , "104" , "105"};
double[] price = { 5.68 , 7.65 , 2.356 , 9.812 , 16.254 };
//Your code goes here
Console.Write("Enter area code : ");
// read complete line
string code = Console.ReadLine();
//Your code goes here
Console.Write("Enter length of time in minutes : ");
// read complete line and convert into integer
int time = Convert.ToInt32(Console.ReadLine());
// store the total cose
double total_cost = 0.0;
int i;
// traverse the array
for( i = 0 ; i < area_code.Length ; i++ )
{
// if the current city code is the required code
if( string.Equals(area_code[i] , code) == true )
{
total_cost = price[i] * (double)time;
break;
}
}
Console.WriteLine("Total Cost : $" + total_cost);
}
}
}
Sample output