Exemple #1
0
        //  Making a Method to Display in Main
        public void CustomersAccount()
        {
            StreamWriter Ac;

            try
            {
                Ac = File.AppendText("C:\\Users\\RON TAYLOR\\Desktop\\Computer Programing\\Customer_Account.txt");

                Console.WriteLine("please enter customers previous reading");
                previous_meter = int.Parse(Console.ReadLine());
                Console.WriteLine("please enter customers current reading");
                current_meter       = int.Parse(Console.ReadLine());
                current_consumption = current_meter - previous_meter;
                Console.ReadLine();
                Ac.WriteLine(previous_meter);
                Ac.WriteLine(current_meter);
                Ac.WriteLine(current_consumption);
                Ac.WriteLine("Previous meter :{0} Current meter: {1} Current consumption :{2}", previous_meter, current_meter, current_consumption);
                Ac.Close();
            }
            catch
            {
                Console.WriteLine(" file not writtten ");
            }
            Console.ReadLine();



            StreamReader Bw;


            Bw = File.OpenText("C:\\Users\\RON TAYLOR\\Desktop\\Computer Programing\\Customer_Account.txt");

            Accdisplay = Bw.ReadLine();
            while (Accdisplay != null)
            {
                Console.WriteLine(Accdisplay);
                Accdisplay = Bw.ReadLine();
            }

            Bw.Close();
        }