Hi there I am trying to a create an Address Book program using an 2d array (only).
The address book must store the Names address, postcodes in a 2d array.
The Naming format must be : Surname , Firstname (e.g. Family name, Given name).
The Address format must be : 7, pembroke, newcity (e.g. Number, Road Name, Town Name)
The menu system must offer the following choices
1 Add Entry
2 Delete Entry
3 Print Book to Screen
4 Edit a Record
5 Search for a record using either Surname, Firstname or Road Name
And the Use of Methods would also help.
the array must start with with strings “XXXXXX” and when a record is deleted replace its value with “XXXXXX”. Any cell containing “XXXXXX” is now available for use.
Sorting of entries alphabetically in the array would be very helpful for the user to read.
Here is my code so far:
using
System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignment_2011{}
class Program
{
static void Main()
{
ArrayList address = new ArrayList { };
Boolean menu = true;
string s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
// Creates a 2d array and loads it
string[,] a = new string[11,2];
public static int Choice;
// Declaring the strings in the array all as X
string s1 = 1.XXXXXX;
string s2 = 2.XXXXXX;
string s3 = 3.XXXXXX;
string s4 = 4.XXXXXX;
string s5 = 5.XXXXXX;
string s6 = 6.XXXXXX;
string s7 = 7.XXXXXX;
string s8 = 8.XXXXXX;
string s9 = 9.XXXXXX;
string s10 = 10.XXXXXX;
string s11 = 11.XXXXXX;
// Main Menu for my console program
do
{
Console.WriteLine("**********************************");
Console.WriteLine("Press 1 to Add a new record");
Console.WriteLine("Press 2 to Remove a record");
Console.WriteLine("Press 3 to Print book to screen");
Console.WriteLine("Press 4 to Quit the program");
Console.WriteLine("Press 5 to Search for a record");
Console.WriteLine("Press 6 to Edit a record");
Console.WriteLine("Press 7 to Save entries to txt file");
Console.WriteLine("Press 8 to Print the txt file");
Converttoin32.Choice = (Console.ReadLine());
if (Choice == 1)
{
Console.WriteLine("Please Enter your Lastname");
string s1 = Console.ReadLine();
Console.WriteLine("Please Enter your Firstname");
string s1 = Console.ReadLine();
Console.WriteLine("Please Enter your Address");
s1 = Console.ReadLine();
Console.WriteLine("Please Enter your Town");
string s1 = Console.ReadLine();
Console.WriteLine("Please Enter your Postcode");
string s1 = Console.ReadLine();
}
if (Choice == 2)
{
Console.WriteLine("Please enter the record you want to remove");
Console.ReadLine();
for int (a.RemoveAt ( myArrayList.IndexOf ( Console.ReadLine(); ) );
a.Sort();
a.Remove("4");
}
if (Choice == 3)
{
for (int i = Choice; i < a.Length / 5; i++)
s1 = a[i,0];
s2 = a[i,1];
s3 = a[i,2];
s4 = a[i,3];
s5 = a[i,4];
s6 = a[i,5];
s7 = a[i,6];
s8 = a[i,7];
s9 = a[i,8];
s10 = a[i,9];
s11 = a[i,11];
Console.WriteLine(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11);
Console.ReadLine();
}
Console.WriteLine();
if (Choice == 5)
{
Console.WriteLine("Please enter the record you like to locate:");
Console.ReadLine();
for (int i = 1; i <= a.Length; i++){if (a[i] == Console.ReadLine())
{Console.WriteLine("Hello there this matches your search");}}
}
if (Choice == 6)
{
}
if (Choice == 7)
{
}
if (Choice == 8)
{
}
} while(menu == true);
CODE]