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). 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: Your phone call to area 715 costs $0.16 per minute For 22 minutes the total is $3.52 If the area code is not in the array, such as 111, the program should not accept a call length, and instead output Sorry - no calls allowed to area 111. Area Code Per-Minute Rate ($) 262 0.07 414 0.10 608 0.05 715 0.16 815 0.24 920 0.14 Figure 6-25 Per-minute phone call rates In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));
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).
Write a
For example if the area code is in the array, such as 715, and the call length is 22 minutes, the output should be:
Your phone call to area 715 costs $0.16 per minute For 22 minutes the total is $3.52
If the area code is not in the array, such as 111, the program should not accept a call length, and instead output Sorry - no calls allowed to area 111.
Area Code | Per-Minute Rate ($) |
---|---|
262 | 0.07 |
414 | 0.10 |
608 | 0.05 |
715 | 0.16 |
815 | 0.24 |
920 | 0.14 |
Figure 6-25 Per-minute phone call rates
In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images