Do part 1 and two There are two parts to this assignment, with two separated 1.
ID: 3725022 • Letter: D
Question
Do part 1 and two
There are two parts to this assignment, with two separated
1. You must examine the requirements for the program and come up with a requirements list for
input data validation for the program. A master requirements list for input data validation will be generated from all teams' submissions that you will use when writing the program.
2. You will write the c program, based on the description below and the additional master
requirements list for input data validation (as per the results of part 1. above).
Milestone 1 – The Requirements List
Your requirements list for input validation should not be a formal document. It must be a text document called req.txt . The requirements should be a bulleted list oriented towards being friendly for the user while still maintaining the integrity of the input data. This is important
Milestone 2 – The Program
Create a c program that takes input for an address book (of people, not businesses), validates the input,
and stores the data in an array. Once the user has entered the desired number of entries, the address
book should be displayed in its entirety.
The data stored consists of:
• Name (maximum length 30 characters)
• Street Address (maximum length 60 characters)
• City (maximum length 60 characters)
• Province (in the format of a 2 character long Canadian province abbreviation used by Canada Post)
• Postal Code (in the format of a Canadian Postal Code)
• Phone Number, including area code
You must prompt the user in a user-friendly way. This requires that the prompt be informative but not
overbearing. If the user enters invalid input, an error message must be displayed indicating what the problem is. The user must be given an option as to whether to skip entering this part of the address book entry (e.g. skip the Address and continue with the City) or to try again. The array of addresses is of size 10. The user will be permitted to enter up to 10 entries. If the user
chooses to end entry early, they can specify this by pressing ENTER as the first and only character of the
name (this is the lone exception to the "pressing ENTER skips a component" requirement).
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:
Fred Flintstone
11 Cobblestone Lane
Bedrock, ON, N2Y 3E8
519-555-1212
++++++++++++
Paginate your output properly (the user should not have to scroll to see output of a single address book
entry.
Do not use regular expressions or any third-party libraries for this assignment.
When the program starts up, display the name (string) that your group has been assigned after
Milestone 1. This will uniquely identify your assignment. Do not put any other identifying information
(e.g. "Fred's Address Book) in the program.
Explanation / Answer
Milestone 1
Validation used for the following fields are as follows:-
• Name
It should be maximum length 30 characters.
• Street Address
It should be maximum length 60 characters.
• City
It should be maximum length 60 characters.
• Province
It should be in the format of a 2 character long
• Postal Code
No validation
• Phone Number
No validation
Milestone 2
#include <stdio.h>
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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.