Question
please modify this c program using the requirements below #include int main(void) { int i,j,len=0; char name[10][30],addr[10][60],city[10][60],province[10][2],postal[10][8],phone[10][13]; printf(Address Book Entry ); for(i=0;i <10;i++) { do
please modify this c program using the requirements below
#include
int main(void)
{
int i,j,len=0;
char name[10][30],addr[10][60],city[10][60],province[10][2],postal[10][8],phone[10][13];
printf("Address Book Entry ");
for(i=0;i<10;i++)
{
do
{
printf("Enter the name ");
scanf("%[^ ]%*c",&name[i]); //Name (maximum length 30 characters)
len=strlen(name[i]);
if(len>30)
printf("Maximum length should be 30 characters ");
} while(len>30);
do
{
printf("Enter the Address "); //Address (maximum length 60 characters)
scanf("%[^ ]%*c",&addr[i]);
len=strlen(addr[i]);
if(len>60)
printf("Maximum length should be 60 characters ");
}while(len>60);
do
{
printf("Enter the City "); //City (maximum length 60 characters)
scanf("%[^ ]%*c",&city[i]);
len=strlen(city[i]);
if(len>60)
printf("Maximum length should be 60 characters ");
}while(len>60);
do
{
printf("Enter the Province "); //Province (2 character long)
scanf("%[^ ]%*c",&province[i]);
len=strlen(province[i]);
if(len>2)
printf("Maximum length should be 2 characters ");
}while(len>2);
printf("Enter the Postal Code "); //postal code`
scanf("%[^ ]%*c",&postal[i]);
printf("Enter the Phone Number "); //Phone Number, including area code
scanf("%[^ ]%*c",&phone[i]);
}
printf(" ");
for(i=0;i<10;i++) //displaying the result
{
printf("%s ",name[i]);
printf("%s ",addr[i]);
printf("%s, %s, %s ",city[i],province[i],postal[i]);
printf("%s ",phone[i]);
printf(" ");
}
return 0;
}
General Assumptions - Only Canadian personal (non-business) addresses - All input can be done in upper or lower case - Assume the case as entered is correct for Name, Address and City o After successful validation, convert lower- to upper-case for Province and Postal Code - No foreign character support required for this version Validation Requirements for Name: - User may enter only a first and last name - Maximum length of 30 characters. - Multiple sequential non-alpha-numeric characters will be considered invalid input - Hyphenated names are acceptable - Legal characters range from a to z, A to Z and include , space (0x20), period and apostrophe - Could contain capitalization within the name Validation requirements for street address: - Will accept alpha-numeric characters in upper and lower case and dash, period, comma and quote should be acceptable - Could contain capitalization within the name - General format: number
For Names, be aware that you might have last names that are two words, like De Groot For Provinces, although only two letter codes are to be stored, it is possible and permissible for the user to enter the full name, two letter code or abbreviation. For example, Ontario, Ont and ON are all valid. (For the abbreviations, just choose some that are reasonable.) The address might will likely have a street type. Just assume there is one, and you do not have to check against a list of valid entries. When the program starts up, display the name Rabbit. Do not put any other identifying information (e.g. "Fred's Address Book) in the program. Once the user has done 10 entries or has chosen to end entry early, the program will then display the contents of the address book, three entries on a page. Each entry will be five lines in size. The lines must be in the following format: Rabbit 11 Cobblestone Lane Bedrock, ON, N2Y 3E8 519-555-1212 ++++++++++++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started