So as Many of u Know or Don't, am Learning C# and Till School Is Over My Learning Progress Will be SLOW.However, i tried to Make a Simple Program That Do Every thing this Pic Shows
Now i need to Know how to make The User CHOOSE From Multi Options , like to Add [Mr , Mrs ... etc] , Emme Showed me b4 but i lost it b4 i look at it ...
Here is The Code
Code:
static void Main(string[] args)
{
StartLabel:
try
{
Console.Write("What is Your Name: ");
string Name1 = Console.ReadLine();
Console.Write("What is Your Mid Name: ");
string Name2 = Console.ReadLine();
Console.Write("What is Your Last Name: ");
string Name3 = Console.ReadLine();
Console.WriteLine("What Is Your Birth Year?");
int year = int.Parse(Console.ReadLine());
Console.WriteLine("What Is Your Birth Month? ");
int month = int.Parse(Console.ReadLine());
Console.WriteLine("What Is Your Birth Day? ");
int day = int.Parse(Console.ReadLine());
DateTime myDOB = new DateTime(year, month, day);
int age = CalcAge(myDOB);
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine("Hello" + " " + Name1 + " " + Name2 + " " + Name3 + " " +"You Are {0} Years Old.", age);
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine("Press Any Key To Close The Program ...");
Console.ReadLine();
}
catch(Exception)
{
Console.WriteLine("Invaild Input , Please Try Again . . . ");
Console.ReadLine();
goto StartLabel;
}
}
public static int CalcAge(DateTime DateOfBirth)
{
DateTime now = DateTime.Today;
int years = now.Year - DateOfBirth.Year;
if (now.DayOfYear < DateOfBirth.DayOfYear)
--years;
return years;
}
}
}
One way you could do this, without giving away that you are trying to determine Mrs, Mr, or Ms would be like this...
It is entirely possible to do this other ways, even ways that use less lines of code, but you can always figure those out
A good idea to do it in code, but not an ideal solution in a real environment. How someone likes to be addressed is preference, particlarly for women (Ie, Ms. or Miss.). You're also dropping chance for people to put other honorifics such as Dr.
IMO, it would be better to leave it open for text, or have a more complete list, maybe contained in an enum - where you'd be able to select which name to use with a number.
Good News To all Brigadier General-General of the Army 11/23/2009 - Soldier Front - 2 Replies if you want to view your EXP if ur Brigadier General to General of the Army
click this !!
?SF?Special Force
to view ur EXP!!!!