TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prime b
NA
810
345.8k
Another array problem
Jan 7 2012 1:31 PM
The problem
Th e Chat-A-While phone company provides service to six
area codes and charges the per-minute rates for phone calls
shown in the accompanying table.
Area Code Per-Minute Rate ($)
262 0.07
414 0.10
608 0.05
715 0.16
815 0.24
920 0.14
Write a program that allows a user to enter an area code and
the length of time for a call in minutes, then display the total
cost of the call.
totalCharge use of unassigned local variable . please help
What I have done so far
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 };
string inputString, inputString1;
int validAreaCode;
double totalCharge, inputLength;
double areaCodexPerMinuteRate = 0;
Console.WriteLine("Pleas enter zipcode ");
inputString = Console.ReadLine();
validAreaCode = Convert.ToInt32(inputString);
Console.WriteLine("Please enter the length of the call");
inputString1 = Console.ReadLine();
inputLength = Convert.ToDouble(inputString1);
bool found = false;
for (int x = 0; x < areaCode.Length; ++x)
{
if( validAreaCode == areaCode[x])
{
found = true;
areaCodexPerMinuteRate = perMinuteRate[x];
totalCharge = areaCodexPerMinuteRate * inputLength;
}
}
if (found)
{
Console.WriteLine(" The call was {0} long and it will cost you {1}", inputLength, totalCharge);
}
else
Console.WriteLine(" We do not support such zipcode");
Reply
Answers (
5
)
How to use Hwnd(c++) type in c#
Loop question please help