using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;
namespace QuickProgram { class Program {
static void Main(string[] args)
{
float[,] data = new float[6, 2]
{
{ 262f, 0.07f },
{ 414f, 0.10f },
{ 608f, 0.05f },
{ 715f, 0.16f },
{ 815f, 0.24f },
{ 920f, 0.14f }
};
float callPrice = 0f;
string areaCode;
string minutes;
while (true)
{
InputAC: Console.Write("Avalible Area Codes:" + Environment.NewLine);
for (int i = 0; i <= 5; i++)
{
Console.Write(data[i, 0] + Environment.NewLine);
}
Console.Write("Input: <Area Code> " + Environment.NewLine);
areaCode = Console.ReadLine();
// Check if areaCode is a valid Area code, and make areaCode into a Double
if (!IsNumber(areaCode))
{
goto InputAC;
}
else
{
bool isAreacode = false;
//Check if is part of array
for (int i = 0; i <= 5; i++)
{
if (Convert.ToDouble(areaCode) == data[i, 0])
{
isAreacode = true;
}
}
if (!isAreacode)
{
Console.Write("Is not Area Code!" + Environment.NewLine);
goto InputAC;
}
}
InputMin: Console.Write(Environment.NewLine + "Input: <Minutes> ");
minutes = Console.ReadLine();
if (!IsNumber(minutes))
{
goto InputMin;
}
for (int i = 0; i <= 5; i++)
{
if (Convert.ToDouble(areaCode) == data[i, 0])
{
callPrice = Convert.ToSingle(minutes) * data[i, 1];
Console.Write("You Will Spend: " + callPrice.ToString() + " $" + Environment.NewLine);
callPrice = 0f;
}
}
}
}
public static Boolean IsNumber(string s)
{
try
{
Convert.ToDouble(s);
return true;
}
catch (Exception e)
{
Console.Write("Exception Caught!" + Environment.NewLine);
return false;
}
}
}
}