none
Need help with Error 1513 RRS feed

  • Question

  • Need help with error, very new to programming, first project in fact

    using System;

    namespace Meem_machine
    {
        class Program
        {
            static void Main(string[] args)
            {

                Console.Write("What is your name? ");
                string name =  Console.ReadLine();
                
                Console.WriteLine("Hello " + name);

                Console.Write("How old are you? ");
                string age = Console.ReadLine();

                Console.Write("What is the date today? ");
                string date = Console.ReadLine();

                Console.WriteLine("Your name is " + name + " and you are " + age + " and the date today is " + date);

                Console.Write("Is this info correct? Enter yes if correct, restart program if not.                                                     ");

                string s = Console.ReadLine();

                if (s == "Yes") ;
                {
                    Console.WriteLine("Welcome" + name);
                }  [ERROR RIGHT HERE]

                else if (s == "No") ;
                {
                    Console.WriteLine("Sorry, please try again."); 

                }
        } 
                
            }
        }

    Friday, April 13, 2018 1:40 PM

Answers

  • Corrected Code

    using System;
    
    namespace Meem_machine
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                Console.Write("What is your name? ");
                string name = Console.ReadLine();
    
                Console.WriteLine("Hello " + name);
    
                Console.Write("How old are you? ");
                string age = Console.ReadLine();
    
                Console.Write("What is the date today? ");
                string date = Console.ReadLine();
    
                Console.WriteLine("Your name is " + name + " and you are " + age + " and the date today is " + date);
    
                Console.Write("Is this info correct? Enter yes if correct, restart program if not.                                                     ");
    
                string s = Console.ReadLine();
    
                if (s == "Yes")
                {
                    Console.WriteLine("Welcome" + name);
                }
    
                else if (s == "No")
                {
                    Console.WriteLine("Sorry, please try again.");
    
                }
            }
        }
    }

    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


    • Edited by Vikram Manjare Friday, April 13, 2018 1:51 PM
    • Marked as answer by WaltJD Friday, April 13, 2018 9:42 PM
    Friday, April 13, 2018 1:48 PM

All replies

  • Corrected Code

    using System;
    
    namespace Meem_machine
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                Console.Write("What is your name? ");
                string name = Console.ReadLine();
    
                Console.WriteLine("Hello " + name);
    
                Console.Write("How old are you? ");
                string age = Console.ReadLine();
    
                Console.Write("What is the date today? ");
                string date = Console.ReadLine();
    
                Console.WriteLine("Your name is " + name + " and you are " + age + " and the date today is " + date);
    
                Console.Write("Is this info correct? Enter yes if correct, restart program if not.                                                     ");
    
                string s = Console.ReadLine();
    
                if (s == "Yes")
                {
                    Console.WriteLine("Welcome" + name);
                }
    
                else if (s == "No")
                {
                    Console.WriteLine("Sorry, please try again.");
    
                }
            }
        }
    }

    Best Regards
    Vikram Manjare
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


    • Edited by Vikram Manjare Friday, April 13, 2018 1:51 PM
    • Marked as answer by WaltJD Friday, April 13, 2018 9:42 PM
    Friday, April 13, 2018 1:48 PM
  • The error is because ; after if (and else if) statement.
    Friday, April 13, 2018 1:48 PM
  • Thanks very much.
    Friday, April 13, 2018 9:43 PM