By GokiSoft.com| 09:40 01/11/2021|
C Sharp

[Examination] Thi thực hành môn C# - C Sharp

Thời Gian Thi: 14h40 - 15h40

Muộn 1 phút trừ 0.5 điểm 

Phản hồi từ học viên

5

(Dựa trên đánh giá ngày hôm nay)

Nguyễn Việt Hoàng [community,AAHN-C2009G]
Nguyễn Việt Hoàng

2021-10-16 08:53:26


#HashTable.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ss12
{
    class HashTable
    {
        public string FullName { get; set; }
        public string PhoneNumBer { get; set; }
        public HashTable()
        {

        }
        public HashTable(string fullname, string phonenumber)
        {
            this.FullName = fullname;
            this.PhoneNumBer = phonenumber;
        }
        public void Input()
        {
            Console.WriteLine("Enter FullName :");
            FullName = Console.ReadLine();
            while(FullName.Length == 0)
            {
                Console.WriteLine("FullName is not Empty");
                Console.WriteLine("Enter FullName Again :");
                FullName = Console.ReadLine();
            }
            Console.WriteLine("Enter Phone NumBer :");
            PhoneNumBer = Console.ReadLine();
            while(PhoneNumBer.Length == 0)
            {
                Console.WriteLine("Phone NumBer is not Empty");
                Console.WriteLine("Enter Phone Number Again :");
                PhoneNumBer = Console.ReadLine();
            }
        }
        public void Display()
        {
            Console.WriteLine("FullName :{0}, PhoneNumBer :{1}", FullName, PhoneNumBer);
        }
    }
}


#Program.cs


using System;
using System.Collections.Generic;

namespace Ss12
{
    class Program
    {
        public static List<HashTable> HastList = new List<HashTable>();
        public static void ShowMenu()
        {
            Console.WriteLine("1.Add new Contact");
            Console.WriteLine("2.Find a Contact by name ");
            Console.WriteLine("3.Display contacts");
            Console.WriteLine("4.Exits");
        }
        public static void ListMenu()
        {
            int choose;
            do
            {
                ShowMenu();
                Console.WriteLine("Enter choose value of Menu");
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Add();
                        break;
                    case 2:
                        FindByName();
                        break;
                    case 3:
                        Display();
                        break;
                    case 4:
                        Console.WriteLine("Exits");
                        return;
                    default:
                        Console.WriteLine("Value must be 1->4");
                        break;
                }
            } while (choose != 4);
        }

        private static void Display()
        {
            if(HastList.Count == 0)
            {
                Console.WriteLine("ConTact does not exists !");
                return;
            }
            Console.WriteLine("Display Contact :");
           foreach(HashTable h in HastList)
            {
                h.Display();
            }
        }

        private static void FindByName()
        {
            if (HastList.Count == 0)
            {
                Console.WriteLine("ConTact does not exists !");
                return;
            }
            int count = 0;
            Console.WriteLine("Enter Name You Need Find :");
            string find = Console.ReadLine();
            foreach(HashTable h in HastList)
            {
                if (h.FullName.Equals(find))
                {
                    h.Display();
                    count++;
                }
            }
            if(count == 0)
            {
                Console.WriteLine("Cannot Find Name ");
            }
        }

        private static void Add()
        {
            Console.WriteLine("Enter Sum Of Contact :");
            int sum = int.Parse(Console.ReadLine());
            for (int i = 0; i < sum; i++){
                Console.WriteLine("Contact[" + (i + 1) + "]");
                HashTable h = new HashTable();
                h.Input();
                HastList.Add(h);
            }
            Console.WriteLine("Add Contact Success");
        }

        static void Main(string[] args)
        {
            ListMenu();
        }
    }
}



Nguyễn Việt Hoàng [community,AAHN-C2009G]
Nguyễn Việt Hoàng

2021-10-16 08:53:26


#HashTable.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ss12
{
    class HashTable
    {
        public string FullName { get; set; }
        public string PhoneNumBer { get; set; }
        public HashTable()
        {

        }
        public HashTable(string fullname, string phonenumber)
        {
            this.FullName = fullname;
            this.PhoneNumBer = phonenumber;
        }
        public void Input()
        {
            Console.WriteLine("Enter FullName :");
            FullName = Console.ReadLine();
            while(FullName.Length == 0)
            {
                Console.WriteLine("FullName is not Empty");
                Console.WriteLine("Enter FullName Again :");
                FullName = Console.ReadLine();
            }
            Console.WriteLine("Enter Phone NumBer :");
            PhoneNumBer = Console.ReadLine();
            while(PhoneNumBer.Length == 0)
            {
                Console.WriteLine("Phone NumBer is not Empty");
                Console.WriteLine("Enter Phone Number Again :");
                PhoneNumBer = Console.ReadLine();
            }
        }
        public void Display()
        {
            Console.WriteLine("FullName :{0}, PhoneNumBer :{1}", FullName, PhoneNumBer);
        }
    }
}


#Program.cs


using System;
using System.Collections.Generic;

namespace Ss12
{
    class Program
    {
        public static List<HashTable> HastList = new List<HashTable>();
        public static void ShowMenu()
        {
            Console.WriteLine("1.Add new Contact");
            Console.WriteLine("2.Find a Contact by name ");
            Console.WriteLine("3.Display contacts");
            Console.WriteLine("4.Exits");
        }
        public static void ListMenu()
        {
            int choose;
            do
            {
                ShowMenu();
                Console.WriteLine("Enter choose value of Menu");
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Add();
                        break;
                    case 2:
                        FindByName();
                        break;
                    case 3:
                        Display();
                        break;
                    case 4:
                        Console.WriteLine("Exits");
                        return;
                    default:
                        Console.WriteLine("Value must be 1->4");
                        break;
                }
            } while (choose != 4);
        }

        private static void Display()
        {
            if(HastList.Count == 0)
            {
                Console.WriteLine("ConTact does not exists !");
                return;
            }
            Console.WriteLine("Display Contact :");
           foreach(HashTable h in HastList)
            {
                h.Display();
            }
        }

        private static void FindByName()
        {
            if (HastList.Count == 0)
            {
                Console.WriteLine("ConTact does not exists !");
                return;
            }
            int count = 0;
            Console.WriteLine("Enter Name You Need Find :");
            string find = Console.ReadLine();
            foreach(HashTable h in HastList)
            {
                if (h.FullName.Equals(find))
                {
                    h.Display();
                    count++;
                }
            }
            if(count == 0)
            {
                Console.WriteLine("Cannot Find Name ");
            }
        }

        private static void Add()
        {
            Console.WriteLine("Enter Sum Of Contact :");
            int sum = int.Parse(Console.ReadLine());
            for (int i = 0; i < sum; i++){
                Console.WriteLine("Contact[" + (i + 1) + "]");
                HashTable h = new HashTable();
                h.Input();
                HastList.Add(h);
            }
            Console.WriteLine("Add Contact Success");
        }

        static void Main(string[] args)
        {
            ListMenu();
        }
    }
}



Nguyễn Anh Vũ [T2008A]
Nguyễn Anh Vũ

2021-05-31 10:22:55


#Program
using System;
using System.Collections.Generic;
namespace Examination
{
    class Program
    {
        static void Main(string[] args)
        {
            List<ContactManager> contactManagersList = new List<ContactManager>;

            int choose ;
            do
            {
                ShowMenu();
                choose = Int32.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Console.WriteLine("Nhap so lien he: ");
                        int n = int.Parse(Console.ReadLine());
                        for (int i = 0; i < n; i++)
                        {
                            ContactManager ht = new ContactManager();
                            ht.input();
                            contactlist.Add(ht);
                        }
                        break;
                    case 2:
                        Console.WriteLine("Nhap ten lien he can tim: ");
                        string name = Console.ReadLine();
                        int num = 0;
                        foreach (ContactManager ht in contactlist)
                        {
                            if (ht.Name == name)
                            {
                                ht.display();
                                num++;
                            }
                        }
                        if (num == 0)
                        {
                            Console.WriteLine("khong tim thay ten");
                        }
                        break;
                    case 3:
                        for (int i = 0; i <contactlist.Count; i++)
                        {
                            contactlist[i].display();
                        }
                        break;
                    case 4:
                        Environment.Exit(0);
                        break;
                    default:
                        Console.WriteLine("Fail!");
                        break;
                }
            } while (choose != 4);
        }

        static void ShowMenu()
        {
            Console.WriteLine("1. Them lien he moi");
            Console.WriteLine("2. Tim so lien lac theo ten");
            Console.WriteLine("3. Hien thi");
            Console.WriteLine("4. Thoat");
            Console.WriteLine("Chon: ");
        }
    }
#ContactManager


using System;
using System.Collections.Generic;
using System.Text;

namespace Examination
{
    class ContactManager
    {
        public string Name { get; set; }
        public string Phone { get; set; }
        public ContactManager()
        {

        }
        public ContactManager(string name, string phone)
        {
            this.Name = name;
            this.Phone = phone;
        }
        public void input()
        {
            Console.WriteLine("Nhap Name: ");
            Name = Console.ReadLine();
            Console.WriteLine("Nhap Phone: ");
            Phone = Console.ReadLine();
        }

        public void display()
        {
            Console.WriteLine("Name: = {0}", Name);
            Console.WriteLine("Phone: = {0}", Phone);
        }
    }
}



Triệu Văn Lăng [T2008A]
Triệu Văn Lăng

2021-05-31 08:58:29


#ContactManager.cs


using System;
using System.Collections.Generic;
using System.Text;

namespace baitest1564
{
    class ContactManager
    {
        public string Name { get; set; }
        public string PhoneNumber { get; set; }

        public ContactManager() { }

        public ContactManager(string Name, string PhoneNumber)
        {
            this.Name = Name;
            this.PhoneNumber = PhoneNumber;
        }

        public void input()
        {
            Console.WriteLine("Enter Name: ");
            Name = Console.ReadLine();

            Console.WriteLine("Enter PhoneNumer: ");
            PhoneNumber = Console.ReadLine();
        }

        public void display()
        {
            Console.WriteLine("{0, -20}{1, -20}", Name, PhoneNumber);

        }
    }
}


#Program.cs


using System;
using System.Collections;
using baitest1564;
namespace baitest1564
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable hashtable = new Hashtable();
            Console.WriteLine("Hello World!");
            int choose = 0;
            do
            {
                showMenu();
                choose = Convert.ToInt32(Console.ReadLine());
                switch(choose)
                {
                    case 1:
                        Console.WriteLine("Enter N: ");
                        int n = Convert.ToInt32(Console.ReadLine());

                        for(int i = 0; i < n; i++)
                        {
                            Console.WriteLine("Enter contact {0}:", i + 1);
                            ContactManager contactManager = new ContactManager();
                            contactManager.input();

                            hashtable.Add(contactManager.Name, contactManager);
                        }
                        break;
                    case 2:
                        Console.WriteLine("Enter the name you want to search: ");
                        string NameSearch = Console.ReadLine();
                        int k = 0;
                        
                        if(hashtable.ContainsKey(NameSearch))
                        {
                            ContactManager c = (ContactManager) hashtable[NameSearch];
                            Console.WriteLine("Name: {0}, Phone number: {1}", c.Name, c.PhoneNumber);
                        } else
                        {
                            Console.WriteLine("Not found");
                        }
                        
                        break;
                    case 3:
                        Console.WriteLine("    Address Book    ");
                        Console.WriteLine("{0,-20}{1,-20}", "Contact Name", "Phone Number");
                        foreach (string key in hashtable.Keys)
                        {
                            ContactManager c = (ContactManager)hashtable[key];
                            c.display();
                        }
                        break;
                    case 4:
                        Console.WriteLine("Exit");
                        break;
                    default:
                        Console.WriteLine("Retype!!!");
                        break;
                }

            } while (choose != 4);
        }

        private static void showMenu()
        {
            Console.WriteLine("1. Add new contact");
            Console.WriteLine("2. Find a contact by name");
            Console.WriteLine("3. Display contacts");
            Console.WriteLine("4. Exit");
            Console.WriteLine("Choose: ");
        }
    }
}



GokiSoft.com [Teacher]
GokiSoft.com

2021-05-31 08:35:50



using System;
namespace Lesson08
{
    public class Contact
    {
        public string Name { get; set; }
        public string PhoneNumber { get; set; }

        public Contact()
        {
        }

        public Contact(string name, string phoneNumber)
        {
            this.Name = name;
            this.PhoneNumber = phoneNumber;
        }

        public void Input()
        {
            Console.WriteLine("Enter name: ");
            Name = Console.ReadLine();

            Console.WriteLine("Enter phone number: ");
            PhoneNumber = Console.ReadLine();
        }

        public void Display()
        {
            Console.WriteLine("{0,-20}{1,-20}", Name, PhoneNumber);
        }
    }
}



using System;
using System.Collections;

namespace Lesson08
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Hashtable contactList = new Hashtable();

            int choose;

            do
            {
                ShowMenu();
                choose = Int32.Parse(Console.ReadLine());

                switch(choose)
                {
                    case 1:
                        Contact contact = new Contact();
                        contact.Input();

                        contactList.Add(contact.Name, contact);
                        break;
                    case 2:
                        Console.WriteLine("Enter name to search: ");
                        string name = Console.ReadLine();

                        if(contactList.ContainsKey(name))
                        {
                            //Tim thay
                            Contact c = (Contact) contactList[name];
                            Console.WriteLine("User's Phone Number: {0}", c.PhoneNumber);
                        } else
                        {
                            Console.WriteLine("Not found!!!");
                        }
                        break;
                    case 3:
                        Console.WriteLine("Address Book");
                        Console.WriteLine("{0,-20}{1,-20}", "Contact Name", "Phone Number");
                        foreach(string key in contactList.Keys)
                        {
                            Contact c = (Contact) contactList[key];
                            c.Display();
                        }
                        break;
                    case 4:
                        Console.WriteLine("Exit!!!");
                        break;
                    default:
                        Console.WriteLine("Input failed!!!");
                        break;
                }
            } while (choose != 4);
        }

        static void ShowMenu()
        {
            Console.WriteLine("1. Add new contact");
            Console.WriteLine("2. Find a contact by name");
            Console.WriteLine("3. Display contacts");
            Console.WriteLine("4. Exit");
            Console.WriteLine("Choose: ");
        }
    }
}



nguyễn Sử [T2008A]
nguyễn Sử

2021-05-31 08:31:13



using System;
using System.Collections.Generic;
using System.Collections;

namespace quanlilienhe
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            string ten;
            string sdt;
            Hashtable Hash = new Hashtable();
            List<Contact_Info> Contact_InfoList = new List<Contact_Info>();

            int chon;
            do
            {
                menu();
                Console.WriteLine("moi nhap lua chon: ");
                chon = Int32.Parse(Console.ReadLine());
                switch (chon)
                {
                    case 1:
                        Console.WriteLine("nhap lien he moi:");
                        int n;
                        n = Int32.Parse(Console.ReadLine());
                        for (int i = 0; i <n; i++)
                        {
                            Contact_Info contact_Info = new Contact_Info();
                            contact_Info.input();
                            Hash.Add(i, contact_Info);
                        }
                        break;
                    case 2:
                        Console.WriteLine("nhap ten can tim: ");
                        string timten = Console.ReadLine();
                        ICollection key1 = Hash.Keys;
                        if (Contact_InfoList.Containskey(ten))
                        {
                            Contact_Info contact_Info = (contact_Info)Contact_InfoList[ten];
                            Console.WriteLine("so dien thoai: {0}", contact_Info.sdt);
                        }
                        else
                        {
                            Console.WriteLine("khong tim thay: ");
                        }
                        break;
                    case 3:
                        Console.WriteLine("hien thi danh ba: ");
                        ICollection key = Hash.Keys;
                        foreach(string a in key)
                        {
                            Console.WriteLine("ten: " + a + ", so dien thoai: " + Hash[key]);
                        }
                        break;
                    case 4:
                        Console.WriteLine("thoat chuong trinh: ");
                        break;
                    default:
                        Console.WriteLine("nhap sai !!!!!!");
                        break;
                }
            } while (chon != 5);

        }
        private static void menu() {
            Console.WriteLine("-------- menu -----------");
            Console.WriteLine("1: them lien he moi:  ");
            Console.WriteLine("2: tim mot so lien lac theo ten: ");
            Console.WriteLine("3: hien thi danh ba:  ");
            Console.WriteLine("4: thoat:  ");
            Console.WriteLine("chon:  ");

        }
    }
    
}



nguyễn Sử [T2008A]
nguyễn Sử

2021-05-31 08:31:03



using System;
using System.Collections.Generic;
using System.Text;

namespace quanlilienhe
{
    class Contact_Info
    {
        public string ten { get; set; }
        public int sdt { get; set; }

        public Contact_Info() { }
        public Contact_Info(string ten, int sdt)
        {
            this.ten = ten;
            this.sdt = sdt;
        }
        public void input()
        {
            Console.WriteLine("nhap ten: ");
            string ten = Console.ReadLine();

            Console.WriteLine("nhap so dien thoai: ");
            int sdt = Int32.Parse(Console.ReadLine());
        }
        public void display()
        {
            Console.WriteLine("ten: {0}, so dien thoai: {1}", ten, sdt);
        }

    }
}



Do Trung Duc [T2008A]
Do Trung Duc

2021-05-31 07:59:49



using System;
using System.Collections.Generic;
using System.Text;

namespace Test.Exam._31._5._2021
{
    class Contact
    {
        public string Name { get; set; }
        public string PhoneNumber { get; set; }

        public Contact() { }

        public Contact(string Name, string PhoneNumber)
        {
            this.Name = Name;
            this.PhoneNumber = PhoneNumber;
        }

        public void Input()
        {
            Console.WriteLine("Nhap ten:");
            Name = Console.ReadLine();

            Console.WriteLine("Nhap SDT: ");
            PhoneNumber = Console.ReadLine();
        }

        public void Display()
        {
            Console.WriteLine("Ten: {0}, SDT: {1}", PhoneNumber, PhoneNumber);
        }

    }
}



Do Trung Duc [T2008A]
Do Trung Duc

2021-05-31 07:59:33



using System;
using System.Collections;

namespace Test.Exam._31._5._2021
{
    class Program
    {
        static Hashtable PhoneList = new Hashtable();
        static void Main(string[] args)
        {
            int choose;
            do
            {
                Menu();
                Console.WriteLine("Nhap lua chon: ");
                choose = Int32.Parse(Console.ReadLine());

                switch (choose)
                {
                    case 1:
                        AddNewContact();
                        break;

                    case 2:
                        FindContactByName();
                        break;

                    case 3:
                        DisplayContacts();
                        break;


                    case 4:
                        Console.WriteLine("Exit...");
                        break;
                }


            } while (choose != 4);
          
            
        }

        private static void DisplayContacts()
        {
            Console.WriteLine("AddressBook");

            foreach (Contact value in PhoneList.Values)
            {
                value.Display();
            }
        }

        private static void FindContactByName()
        {
            int count = 0;
            Console.WriteLine("Nhap ten nguoi muon tim contact: ");
            string FindName = Console.ReadLine();


            foreach (Contact value in PhoneList.Values)
            {
                if (value.Name == FindName)
                {
                    Console.WriteLine("So dien thoai nguoi ban tim la: " + value.PhoneNumber);
                    count = count + 1;
                }
            }
            if(count == 0)
            {
                Console.WriteLine("Nguoi ban tim so dien thoai khong co trong danh sach");
            }

     
        }

        private static void AddNewContact()
        {
            Console.WriteLine("Nhap so luong contact muon them: ");
            int N = Int32.Parse(Console.ReadLine());

                for(int i = 0; i < N; i++)
            {
                Contact contact = new Contact();
                contact.Input();
                PhoneList.Add(i, contact);
            }

            Console.WriteLine("Nhap du lieu thanh cong: ");
        }

        static void Menu()
        {
            Console.WriteLine("1. Add new contact");
            Console.WriteLine("2. Find contact by name");
            Console.WriteLine("3. Display contacts");
            Console.WriteLine("4. Exit");
        }
    }
}



Nguyễn Tiến Đạt [T2008A]
Nguyễn Tiến Đạt

2021-05-31 07:55:39


#Program.cs


using System;
using System.Collections;
using ExamHashTable.Modals;

namespace ExamHashTable
{
    class Program
    {
        public static Hashtable list = new Hashtable();
        static void Main(string[] args)
        {
            int choose = 0;
            Contact contact = new Contact();
            do
            {
                showMenu();
                choose = int.Parse(Console.ReadLine());
                switch (choose)
                {
                    case 1:
                        Console.WriteLine("Input name:");
                        string name = Console.ReadLine();
                        Console.WriteLine("Input telnum:");
                        string phone = Console.ReadLine();
                        Contact c = new Contact(name, phone);
                        contact.Add(phone, c);
                        break;
                    case 2:
                        Console.WriteLine("Name to search:");
                        string nameFound = Console.ReadLine();
                        contact.Find(nameFound);
                        break;
                    case 3:
                        Console.WriteLine("               Address Book");
                        Console.WriteLine("Contact name                  Phone number");
                        foreach (string key in list.Keys)
                        {
                            Contact contact1 = (Contact)list[key];
                            contact1.Display();
                            
                        }
                        break;
                    case 4:
                        Console.WriteLine("Goodbye!!");
                        break;
                    default:
                        Console.WriteLine("Error program!!");
                        break;
                }
            } while (choose != 4);
        }
        private static void showMenu()
        {
            Console.WriteLine("Select program:");
            Console.WriteLine("1.Add a new contact");
            Console.WriteLine("2.Find a contact by name");
            Console.WriteLine("3.Display contacts");
            Console.WriteLine("4.Exit");
        }
    }
}


#Contact.cs


using System;
using System.Collections.Generic;
using System.Text;
using ExamHashTable;

namespace ExamHashTable.Modals
{
    class Contact
    {
        public string name { get; set; }
        public string phone { get; set; }
        public Contact()
        {

        }
        public Contact(string name, string phone)
        {
            this.name = name;
            this.phone = phone;
        }
        public void Add(string phone, Contact contact)
        {
            Program.list.Add(phone,contact);
        }
        public void Display()
        {
            Console.WriteLine("{0,-30}{1}", name, phone);
        }
        public void Find(string name)
        {
            int check = 0;
            foreach (string key in Program.list.Keys)
            {
                Contact contact = (Contact)Program.list[key];
                if (contact.name == name)
                {
                    check++;
                    Console.WriteLine("               Address Book");
                    Console.WriteLine("Contact name                  Phone number");
                    break;
                }

            }
            if (check == 0) Console.WriteLine("The contact is not found!!");
            else
            {
                foreach (string key in Program.list.Keys)
                {
                    Contact contact = (Contact)Program.list[key];
                    if (contact.name == name)
                    {
                        contact.Display();
                    }

                }
            }
        }
    }
}