Code:
using System;
using System.IO;
using System.Text;
namespace Program_Test
{
public class Default
{
public class Human//Make your class
{
public int age, weight;
public float height;
public string First_name, Last_Name, Middle_Name, Gender;
};
public static void Main(string[] args)
{
try//try for the Stream Writer
{
Console.Title = "Human Creation";
Console.WriteLine("Welcome To Human Creation.\n Do You Want To Create A New Human? \n (Y/N)\n");
string answer = Console.ReadLine();
if (answer == "Y")
{
Console.WriteLine("Good Now Lets Get Started...\n");
Console.WriteLine("Enter In The New Humans Name(First Name)\n");
Human new1 = new Human();//Creating a Variable off of The Class "Human"
new1.First_name = Console.ReadLine();
Console.WriteLine("Enter In The Humans's Middle Name");
new1.Middle_Name = Console.ReadLine();
Console.WriteLine("Enter In The Humans Last Name");
new1.Last_Name = Console.ReadLine();
Console.WriteLine("Good here Is The Info So Far");
Console.WriteLine("First Name {0}, Middle Name {1} , Last Name {2}", new1.First_name, new1.Middle_Name, new1.Last_Name);
String initials = new1.First_name[0].ToString() + "." + new1.Middle_Name[0].ToString() + "." + new1.Last_Name[0].ToString();
//Initials as you know are the first char of every Name ( Fist Middle Last)
//So i just used the first char in the array index[0] and converted it to string
Console.WriteLine("And The Initials {0}", initials);
Console.ReadLine();
Console.Clear();
Console.WriteLine("***********************\n Physical Attributes\n***********************");
Console.WriteLine("Enter The Age Of Your Human");
new1.age = Int32.Parse(Console.ReadLine());
Console.WriteLine("Enter The Height Of Your Human i.e 5.11");
new1.height = float.Parse(Console.ReadLine());// float for decimals
Console.WriteLine("Enter The Weight Of Your Human");
new1.weight = Int32.Parse(Console.ReadLine());
Console.WriteLine("Is Your Human Male Or Female(Male|Female)");
new1.Gender = Console.ReadLine();
StreamWriter Info = new StreamWriter("Human.txt",true , Encoding.ASCII);//Makes a new Stream Writer , ASCII Encoding bool as true
Info.WriteLine("***Personal Information***\n");
Info.WriteLine("Humans Name: {0} {1} {2}\nInitials: {3}", new1.First_name, new1.Middle_Name, new1.Last_Name, initials);
Info.WriteLine("***Physical Attributes***\n");
Info.WriteLine("Age: {0} \n Height: {1} \n Weight: {2} \n Gender: {3}",new1.age,new1.height,new1.weight,new1.Gender);
Info.Close();//Closes the Stream Writer
}
else
{
Console.WriteLine("Exiting...");
System.Threading.Thread.Sleep(500);
Environment.Exit(0);
}
}
catch (Exception Exc)
{
Console.WriteLine("Exception {0}", Exc);//Exceptions
Console.ReadLine();
}
finally
{
Console.WriteLine("Human Created! Exiting...");//FINALLY
System.Threading.Thread.Sleep(500);
Environment.Exit(0);
}
}
}
}
Syntax Highlighting
http://pastebin.com/m2d192446