0

Hi can anyone please help me with my homework assignment? I am not asking anyone to do this for me but I keep getting an error in declaring GetInput() inside Main. It says Error: No overload for method GetInput() takes 0 arguments and I can not figure out what I am doing wrong. Any help would be appreciated thanks!

namespace wk1_ilab
{
    class Program
    {
        
        public static void Main(string[] args)
        {
            DisplayApplicationInformation();
            GetInput();
        }
       public static void DisplayApplicationInformation()
        {
            Console.WriteLine("Welcome to the basic user interface");
            Console.WriteLine("CIS247 Week1 iLab");
            Console.WriteLine("This program accepts user input as a string, then makes the appropriate data conversion");

        }
        
        public static void GetInput(string userName)
        {
            userName = Convert.ToString(Console.Read());
            Console.WriteLine(userName);
        }
        public static void GetInput(int userAge)
        {
            userAge = Convert.ToInt32(Console.Read());
            Console.WriteLine(userAge);
        }
        public static void GetInput(double gas)
        {
            gas = Convert.ToDouble(Console.Read());
            Console.WriteLine(gas);
        }
            
        public void TerminateProgram()
        {
            Console.WriteLine("Thanks for using this program, it will now terminate!");
        }

    }
}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

In your method GetInput you have a parameter, which you do NOT pass it. Do it this way:

public static void Main(string[] args)
        {
            DisplayApplicationInformation();
            string someName = "this is some name";
            GetInput(someName); //here you have to put a parameter to pass with a method
        }
        
        public static void GetInput(string userName) //because here you have declared a parameter
        {
            userName = Convert.ToString(Console.Read());
            Console.WriteLine(userName);
        }

Or remove parameters on boths sides, or you have to have them on both sides.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.