none
need help with cs1513 error RRS feed

  • Question

  • hey need help with code not sure whats wrong, new to programming

    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."); 

                }
        } 
                
            }
        }

    Friday, April 20, 2018 1:16 PM

All replies

  • There should not be ';' after If clause.

                 if (s == "Yes") 
                {
                    Console.WriteLine("Welcome" + name);
                }
                else if (s == "No") 
                {
                    Console.WriteLine("Sorry, please try again.");

                }


    • Proposed as answer by PravinKadam Friday, April 20, 2018 1:40 PM
    • Unproposed as answer by PravinKadam Friday, April 20, 2018 1:42 PM
    • Proposed as answer by CoolDadTxModerator Friday, April 20, 2018 2:01 PM
    Friday, April 20, 2018 1:40 PM