I left a long gap from my last post and I apologize to those who were interested in reading more.
Building on the prior lesson we are going to use a switch statement to analyze input. This program will ask to enter a the user's name and if the users name matches any of the entries within the switch statement it will spit out a custom greeting. If there is no match, a default greeting will appear.
So basically you can enter YOUR NAME, Bill Gates, M. Shadows or Snoop Dogg and get a custom greeting. If you enter any other name you will get the default greeting noted towards the end of the SWITCH statement.
/// Testing out the Switch Statement
/// You can enter four different names that will result
/// in a custom response. All other names will get a
/// default response. Make sure to substitute your name
/// in the first case statement.
static void Main(string args)
//Two strings used.
string fullName, greeting;
Console.Write("Please enter your name: ");
//Assign ‘fullName’ our Console.Readline() value
fullName = Console.ReadLine();
//Analyze the entered string value
//replace with your name!
case "YOUR NAME":
greeting = "You are the best man!!";
case "Bill Gates":
greeting = "You are super wealthy.";
case "Snoop Dogg":
greeting = "You are known for rap.";
case "M. Shadows":
greeting = "Lead singer of A7X?";
greeting = "I'm sorry I did not recognize you!";
}//end switch statement
//Display the custom greeting based on the name entered.
//Give user option to exit
Console.WriteLine("Press [ENTER] to Exit");
}//end class "switchStatement
Now if you enter all lower cases (i.e. snoop dogg) as opposed to Snoop Dogg, you will get the default greeting. If I am not mistaken, (anyone correct me if I am wrong) this is because lowercase letters have different values than uppercase and the conditional will not evaluate.
Well I hope this furthers your progress. The next lesson will cover mathematical operators. BTW this is still a console app.