Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# using Microsoft Visual Studio 2015 This is not only a console based applicati

ID: 667413 • Letter: C

Question

C# using Microsoft Visual Studio 2015

This is not only a console based application like I found elsewhere on here

Create an application in which a user can enter a phone book entry, including the following elements:

First Name, Last Name, Phone Number, e-mail address (add additional elements as desired)

Include a search criteria based on last name or any of the elements created for your phone book entries in order to retrieve the information requested.

You may use MS Access as your database to store and retrieve from the data of your phone book entries.

Be sure to include a write-up with your assignment describing the difference of procedural code versus the use of procedural programming conceptually as used in various program languages.

Save the project as DatabaseTools.cs.

Explanation / Answer

using System;

using System.Collections;

using System.IO;

class PhoneBook

{

    static void Main(string[] arg)

    {

        Hashtable tab = new Hashtable();

        string fileName;

        if

        {

            (arg.Length > 0) fileName = arg[0];
        }

        else

        {

            fileName = "phoneBook.txt";

        }

        StreamReader r = File.OpenText(fileName);

        string line = r.ReadLine();

        while (line != null)

        {

            int pos = line.IndexOf('=');

            string name = line.Substring(0, pos).Trim();

            long phone = Convert.ToInt64(line.Substring(pos + 1));

            tab[name] = phone;

            line = r.ReadLine();

        }

        r.Close();

       for (; ; )

       {

            Console.Write("Name : ");

            string name = Console.ReadLine().Trim();

            if (name == "")

               break;
            object phone = tab[name];

            if (phone == null)

                Console.WriteLine("-- Not Found in Phone Book");

            else

                Console.WriteLine(phone);

        }

    }

}