This is my program, but it is giving me an error stating a Operator '*' cannot be applied to operands of type 'double[]' and 'double'. Can some one tell me how to fix this program.

The Chart-A-While phone company provides service to six codes and charges the following per minute rate for phone calls:
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 times for a call in minutes, then display the total cost of the call.

class Program
{
    static void Main()
        {
            //Declare variables
            int[] VaildAreaCode = { 262, 414, 608, 715, 815, 920 };
            double [] perminuterate = { 0.07, 0.10, 0.05, 0.16, 0.24, 0.14 };
            string inputString;
            double Totalcost;
            double lengthoftime;
            int AreaCode;
           
            Console.Write("Enter Area Code:\n");
            inputString = Console.ReadLine();
            AreaCode = Convert.ToInt32(inputString);

            Console.Write("Enter the length of Time:\n");
            inputString = Console.ReadLine();
            lengthoftime = Convert.ToInt32(inputString);

           Totalcost = perminuterate * lengthoftime;
            
               Console.WriteLine("AreaCode {0} Totalcost for {1}",
                    AreaCode, Totalcost.ToString("C"));
            

        }
    }

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

'perminuterate' is an array which means it has multiple values. Which one did you want to multiply 'lengthoftime' by?

I want to display length of time for a call in minutes. I want to display a new vaiable nane totalcost to give the perminuterate * lengthoftime; The lenthoftime should be inputed by the user.

Please use code tags!
Instead of Totalcost = perminuterate * lengthoftime;
use Totalcost = perminuterate[index] * lengthoftime;
Now all you have to do is determine that index, wich depends on the area code input by the user and you can determine from your VaildAreaCode array.
Success!

sorry i donot know what to do. Please show me what to do.

Momerath is saying you cannot multiply some double value with double array value. No go.

You have this code:

double [] perminuterate = { 0.07, 0.10, 0.05, 0.16, 0.24, 0.14 };

What are these numbers mean?
And you have to select ONLY one value from this double array to multiply with user`s input, like:

double [] perminuterate = { 0.07, 0.10, 0.05, 0.16, 0.24, 0.14 };
double userInput = 0M;
double result = 0M;
if(double.TryParse(Console.ReadLine(), out userInput)
{
    //now you have user`s input in correct type, you only habe to select one value from array
    //but which one, this is up to you.
    //example: I will choose 3rd (0.05):
    result = userOutPut * perminuterate[2];
}
Console.WriteLine("Result is {0}.", result.Tostring());
Console.ReadLine();

The program is asking to display the total cost of the call. The program you gave does not work even if i use it as is. Can someone help me fix my program.

The Chart-A-While phone company provides service to six codes and charges the following per minute rate for phone calls:
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 times for a call in minutes, then display the total cost of the call.

int x;
            string inputString;
            double Totalcost;
            double lengthoftime;
            int AreaCode;
            bool isAreaCode;
            int[] VaildAreaCode = { 262, 414, 608, 715, 815, 920 };
            double[] perminuterate = { 0.07, 0.10, 0.05, 0.16, 0.24, 0.14 };

            Console.Write("Please Enter an Area Code: ");
            inputString = Console.ReadLine();
            AreaCode = Convert.ToInt32(inputString);

            Console.Write("Please Enter the length of Time:");
            inputString = Console.ReadLine();
            lengthoftime = Convert.ToInt32(inputString);

            x = 0;
            isAreaCode = false;
            while (x < VaildAreaCode.Length &&
               AreaCode != VaildAreaCode[x])
                ++x;
            if (x != VaildAreaCode.Length)
            {
                isAreaCode = true;
            }

            if (isAreaCode)
            {
                Totalcost = perminuterate * lengthoftime;

                Console.WriteLine("AreaCode {0} Totalcost for {1}",
                    AreaCode, Totalcost.ToString("C"));
            }

            else
                Console.WriteLine("No such AreaCode as {0}",
                   AreaCode);
           
           
        }
    }
}

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

Please do not get frustrated with me. I am a newbie with programming, and even though you made the suggestion with the index i am not understanding.

No CeeGee, I'm not in the least frustrated by you. But it seems to me that you are showing no effort(Tell me if I'm wrong) :)
Do you know the concept of an array and what an index is?

I am truly trying to the point of tears from frustration. I am trying to complete assignments with the helpo of the text but i am not understanding it all. And no i donot know what an index is.

sorry about not using code tag guys. just found out how to do it. Hope this is correct.

Edited 5 Years Ago by Ezzaral: Removed unnecessary TEX tags.

Nope.
Select your code and select the thing on the left of the TeX button.
Leran the concept of an array on MSDN.

This question has already been answered. Start a new discussion instead.