SlideShare a Scribd company logo
1 of 7
Student Lab Activity
CIS170 Week 6 Lab Instructions
Lab 7 of 7: Sequential Files
Lab Overview—Scenario/Summary
You will code, build, and execute a program that requires
sequential files to create an address database.
Learning Outcomes
1. Continue using a menu system with console applications.
2. Be able to write a console application.
3. Demonstrate entering, appending, storing, and retrieving
records.
4. Be able to write lines of output to a text file in order to
create a report.
Deliverables
Section
Deliverable
Points
Lab
Program Listing and Output
40
All Steps
Total
40
Lab Steps
Preparation:
If you are using the Citrix remote lab, follow the login
instructions located in the lab area in Course Home.
Locate the Visual Studio icon and launch the application.
Lab:
Step 1: Requirements: An Address Database
Create a C++ console application that will store and retrieve
names and addresses in a text file.
The program should do the following.
1. It should accept a series of names and addresses from the
console.
2. The user's input should be written to a text file in the CSV
format described in the lesson, but do not include the field
names in the first row of the file. Use a delimiter to separate the
records.
3. Read the records from the text file, and display them in a
user-friendly format.
4. Provide a menu to allow the user to append records to the
file, display the records, or exit the application.
Build upon the code below to complete the assignment.
//Specification: Append and display records in a address
database
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void menu(void);
void writeData(void);
void readData(void);
const char FileName[] = "TestAddress.txt";
int main () {
menu();
return 0;
} //end main
void menu(void) {
//allow user to choose to append records, display records or exit
the program
}//end menu
void writeData(void){
//Write the Address Info to a file
//loop while user still has data to write to file
//eg outStream<<name<<”#”; //where # is the delimiter
}//end write data
void readData(void){
//read data from a file
//use the split function to break a
//deliminated line of text into fields
ifstream inMyStream (FileName);
if (inMyStream.is_open()) {
//set character to use as a line between record
displays
string recBreaks = "";
recBreaks.assign(20,'-');
int fieldCount = 0; //keep track of the number of
fields read
int recordCount = 1; //keep track of the number of
records read
//read the first field
fieldCount = 1;
string fieldBuffer;
getline (inMyStream, fieldBuffer, '#');
while (!inMyStream.eof() ){
//display the field
switch (fieldCount) {
case 1:
cout << recBreaks << endl;
cout << "record # " << recordCount
<< endl;
cout << "Name...." << fieldBuffer <<
endl; break;
case 2:
cout << "Street.." << fieldBuffer <<
endl; break;
case 3:
cout << "City...." << fieldBuffer <<
endl; break;
case 4:
cout << "State..." << fieldBuffer <<
endl; break;
case 5:
cout << "Zip....." << fieldBuffer <<
endl;
fieldCount = 0;
recordCount++; break;
}
//read the next field
getline (inMyStream, fieldBuffer, '#');
fieldCount++;
}
cout << recBreaks << endl;
inMyStream.close();
}//end read data
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the
requirements.
The pseudocode for the writeData function is shown below.
Start
open the text file to append
start do while loop
Allow user to enter name
store name (using getline method)
Allow user to enter city
store city (using getline method)
.
.
write name, city, etc. to the file
end loop
close the file
End
The program input should appear similar to this.
Append Records
Name..........John Smith
Street.........902 Union Ave
City............Any Town
State...........TX
Zip Code......78552
"Enter another Record? (Y/N) "
The file structure should look like this.
John Smith, 902 Union Ave, Any Town, TX, 79552
Eric Jones, 345 State Way, Fresno, CA, 93432
...
The file output should appear similar to the following.
Show Records
__________________________________________
Record #1
Name...........John Smith
Street..........902 Union Ave
City.............Any Town
State...........TX
Zip Code......78552
__________________________________________
Record #2
Name...........Eric Jones
Street..........345 State Way
City.............Fresno
State...........CA
Zip Code.......93432
__________________________________________
(A)ppend Records, (S)how Records, (E)xit
Step 3: Create a New Project
Create a new project and name it LAB7. Write your code using
the processing logic in Step 2. Make sure you save your
program.
Step 4: Compile and Execute
a) Compile your program. Eliminate all the syntax errors.
b) Build your program and verify the results of the program.
Make corrections to the program logic, if necessary, until the
results of the program execution are what you expect.
Step 5: Print Screenshots and Program
1. Capture a screen print of your output. (Do a print screen and
paste into an MS Word document.)
2. Copy your code and paste it into the same MS Word
document that contains the screen print of your output.
3. Save the Word document as Lab07_LastName_FirstInitial.
END OF LAB
Version 1.0 Page 1 of 9
4/9/2009 Lab Activity CIS CIS170B-A1.docx
Page 1 of 5
Lab Activity CIS CIS170C-A7

More Related Content

Similar to Student Lab Activity CIS170 Week 6 Lab Instructions.docx

Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++Shyam Gupta
 
System programmin practical file
System programmin practical fileSystem programmin practical file
System programmin practical fileAnkit Dixit
 
Working with the IFS on System i
Working with the IFS on System iWorking with the IFS on System i
Working with the IFS on System iChuck Walker
 
Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Abdullah khawar
 
Managing console i/o operation,working with files
Managing console i/o operation,working with filesManaging console i/o operation,working with files
Managing console i/o operation,working with filesramya marichamy
 
Managing,working with files
Managing,working with filesManaging,working with files
Managing,working with fileskirupasuchi1996
 
Exmaples of file handling
Exmaples of file handlingExmaples of file handling
Exmaples of file handlingsparkishpearl
 
C programming session 01
C programming session 01C programming session 01
C programming session 01Dushmanta Nath
 
C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introductionraghukatagall2
 
rmarkdown.pdf
rmarkdown.pdfrmarkdown.pdf
rmarkdown.pdfTheZephyr
 
Computerscience 12th
Computerscience 12thComputerscience 12th
Computerscience 12thJUSTJOINUS
 
Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Rex Joe
 

Similar to Student Lab Activity CIS170 Week 6 Lab Instructions.docx (20)

Stream classes in C++
Stream classes in C++Stream classes in C++
Stream classes in C++
 
System programmin practical file
System programmin practical fileSystem programmin practical file
System programmin practical file
 
Working with the IFS on System i
Working with the IFS on System iWorking with the IFS on System i
Working with the IFS on System i
 
Srgoc dotnet
Srgoc dotnetSrgoc dotnet
Srgoc dotnet
 
Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)Pf cs102 programming-8 [file handling] (1)
Pf cs102 programming-8 [file handling] (1)
 
Managing console i/o operation,working with files
Managing console i/o operation,working with filesManaging console i/o operation,working with files
Managing console i/o operation,working with files
 
Managing,working with files
Managing,working with filesManaging,working with files
Managing,working with files
 
Exmaples of file handling
Exmaples of file handlingExmaples of file handling
Exmaples of file handling
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
C Programming ppt for beginners . Introduction
C Programming ppt for beginners . IntroductionC Programming ppt for beginners . Introduction
C Programming ppt for beginners . Introduction
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
rmarkdown.pdf
rmarkdown.pdfrmarkdown.pdf
rmarkdown.pdf
 
Linux com
Linux comLinux com
Linux com
 
Computerscience 12th
Computerscience 12thComputerscience 12th
Computerscience 12th
 
Lab 1 Essay
Lab 1 EssayLab 1 Essay
Lab 1 Essay
 
Files in c++
Files in c++Files in c++
Files in c++
 
Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01Filesinc 130512002619-phpapp01
Filesinc 130512002619-phpapp01
 

More from florriezhamphrey3065

IDEA requires IEP teams to notify parents of their rights and proced.docx
IDEA requires IEP teams to notify parents of their rights and proced.docxIDEA requires IEP teams to notify parents of their rights and proced.docx
IDEA requires IEP teams to notify parents of their rights and proced.docxflorriezhamphrey3065
 
ID Task ModeTask Name Duration Start Finish Predecesso.docx
ID Task ModeTask Name Duration Start Finish Predecesso.docxID Task ModeTask Name Duration Start Finish Predecesso.docx
ID Task ModeTask Name Duration Start Finish Predecesso.docxflorriezhamphrey3065
 
Id like for us to use our sociological imagination. C. Wright M.docx
Id like for us to use our sociological imagination. C. Wright M.docxId like for us to use our sociological imagination. C. Wright M.docx
Id like for us to use our sociological imagination. C. Wright M.docxflorriezhamphrey3065
 
IAHTopic  Whose work goes into space science How do different .docx
IAHTopic  Whose work goes into space science How do different .docxIAHTopic  Whose work goes into space science How do different .docx
IAHTopic  Whose work goes into space science How do different .docxflorriezhamphrey3065
 
I211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docxI211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docxflorriezhamphrey3065
 
I.Mulcahy’s qualifications1. As a Xerox board member, do yo.docx
I.Mulcahy’s qualifications1. As a Xerox board member, do yo.docxI.Mulcahy’s qualifications1. As a Xerox board member, do yo.docx
I.Mulcahy’s qualifications1. As a Xerox board member, do yo.docxflorriezhamphrey3065
 
I. Many of you may believe that you have never worked in project  ma.docx
I. Many of you may believe that you have never worked in project  ma.docxI. Many of you may believe that you have never worked in project  ma.docx
I. Many of you may believe that you have never worked in project  ma.docxflorriezhamphrey3065
 
i1) The culture you have selected and some general information a.docx
i1) The culture you have selected and some general information a.docxi1) The culture you have selected and some general information a.docx
i1) The culture you have selected and some general information a.docxflorriezhamphrey3065
 
I. Use Venn diagrams to test the validity of the following arguments.docx
I. Use Venn diagrams to test the validity of the following arguments.docxI. Use Venn diagrams to test the validity of the following arguments.docx
I. Use Venn diagrams to test the validity of the following arguments.docxflorriezhamphrey3065
 
I.Context and Situation AnalysisLiberia is a country div.docx
I.Context and Situation AnalysisLiberia is a country div.docxI.Context and Situation AnalysisLiberia is a country div.docx
I.Context and Situation AnalysisLiberia is a country div.docxflorriezhamphrey3065
 
I. Defining Facta. Value free” packets of information; Ex 5’10.docx
I. Defining Facta. Value free” packets of information; Ex 5’10.docxI. Defining Facta. Value free” packets of information; Ex 5’10.docx
I. Defining Facta. Value free” packets of information; Ex 5’10.docxflorriezhamphrey3065
 
I  only need 100 words minimum response for the following several pa.docx
I  only need 100 words minimum response for the following several pa.docxI  only need 100 words minimum response for the following several pa.docx
I  only need 100 words minimum response for the following several pa.docxflorriezhamphrey3065
 
I. PurposeThe purpose of this experiential learning activity.docx
I. PurposeThe purpose of this experiential learning activity.docxI. PurposeThe purpose of this experiential learning activity.docx
I. PurposeThe purpose of this experiential learning activity.docxflorriezhamphrey3065
 
I would sooner believe that two Yankee professors lied, than th.docx
I would sooner believe that two Yankee professors lied, than th.docxI would sooner believe that two Yankee professors lied, than th.docx
I would sooner believe that two Yankee professors lied, than th.docxflorriezhamphrey3065
 
I wrote my paper and my feed back was- This is supposed to be a prof.docx
I wrote my paper and my feed back was- This is supposed to be a prof.docxI wrote my paper and my feed back was- This is supposed to be a prof.docx
I wrote my paper and my feed back was- This is supposed to be a prof.docxflorriezhamphrey3065
 
I would like to discuss my experience developing and implementing .docx
I would like to discuss my experience developing and implementing .docxI would like to discuss my experience developing and implementing .docx
I would like to discuss my experience developing and implementing .docxflorriezhamphrey3065
 
I would do it myself, but I have been taking care of my sick child. .docx
I would do it myself, but I have been taking care of my sick child. .docxI would do it myself, but I have been taking care of my sick child. .docx
I would do it myself, but I have been taking care of my sick child. .docxflorriezhamphrey3065
 
I would have to identify the character Desiree.  I chose Desiree for.docx
I would have to identify the character Desiree.  I chose Desiree for.docxI would have to identify the character Desiree.  I chose Desiree for.docx
I would have to identify the character Desiree.  I chose Desiree for.docxflorriezhamphrey3065
 
I would appreciate your help on this!Prepare a version of Final .docx
I would appreciate your help on this!Prepare a version of Final .docxI would appreciate your help on this!Prepare a version of Final .docx
I would appreciate your help on this!Prepare a version of Final .docxflorriezhamphrey3065
 
I will give you an example of the outline paper from my teacherI.docx
I will give you an example of the outline paper from my teacherI.docxI will give you an example of the outline paper from my teacherI.docx
I will give you an example of the outline paper from my teacherI.docxflorriezhamphrey3065
 

More from florriezhamphrey3065 (20)

IDEA requires IEP teams to notify parents of their rights and proced.docx
IDEA requires IEP teams to notify parents of their rights and proced.docxIDEA requires IEP teams to notify parents of their rights and proced.docx
IDEA requires IEP teams to notify parents of their rights and proced.docx
 
ID Task ModeTask Name Duration Start Finish Predecesso.docx
ID Task ModeTask Name Duration Start Finish Predecesso.docxID Task ModeTask Name Duration Start Finish Predecesso.docx
ID Task ModeTask Name Duration Start Finish Predecesso.docx
 
Id like for us to use our sociological imagination. C. Wright M.docx
Id like for us to use our sociological imagination. C. Wright M.docxId like for us to use our sociological imagination. C. Wright M.docx
Id like for us to use our sociological imagination. C. Wright M.docx
 
IAHTopic  Whose work goes into space science How do different .docx
IAHTopic  Whose work goes into space science How do different .docxIAHTopic  Whose work goes into space science How do different .docx
IAHTopic  Whose work goes into space science How do different .docx
 
I211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docxI211 – Information Infrastructure IILecture 20TodayCGI.docx
I211 – Information Infrastructure IILecture 20TodayCGI.docx
 
I.Mulcahy’s qualifications1. As a Xerox board member, do yo.docx
I.Mulcahy’s qualifications1. As a Xerox board member, do yo.docxI.Mulcahy’s qualifications1. As a Xerox board member, do yo.docx
I.Mulcahy’s qualifications1. As a Xerox board member, do yo.docx
 
I. Many of you may believe that you have never worked in project  ma.docx
I. Many of you may believe that you have never worked in project  ma.docxI. Many of you may believe that you have never worked in project  ma.docx
I. Many of you may believe that you have never worked in project  ma.docx
 
i1) The culture you have selected and some general information a.docx
i1) The culture you have selected and some general information a.docxi1) The culture you have selected and some general information a.docx
i1) The culture you have selected and some general information a.docx
 
I. Use Venn diagrams to test the validity of the following arguments.docx
I. Use Venn diagrams to test the validity of the following arguments.docxI. Use Venn diagrams to test the validity of the following arguments.docx
I. Use Venn diagrams to test the validity of the following arguments.docx
 
I.Context and Situation AnalysisLiberia is a country div.docx
I.Context and Situation AnalysisLiberia is a country div.docxI.Context and Situation AnalysisLiberia is a country div.docx
I.Context and Situation AnalysisLiberia is a country div.docx
 
I. Defining Facta. Value free” packets of information; Ex 5’10.docx
I. Defining Facta. Value free” packets of information; Ex 5’10.docxI. Defining Facta. Value free” packets of information; Ex 5’10.docx
I. Defining Facta. Value free” packets of information; Ex 5’10.docx
 
I  only need 100 words minimum response for the following several pa.docx
I  only need 100 words minimum response for the following several pa.docxI  only need 100 words minimum response for the following several pa.docx
I  only need 100 words minimum response for the following several pa.docx
 
I. PurposeThe purpose of this experiential learning activity.docx
I. PurposeThe purpose of this experiential learning activity.docxI. PurposeThe purpose of this experiential learning activity.docx
I. PurposeThe purpose of this experiential learning activity.docx
 
I would sooner believe that two Yankee professors lied, than th.docx
I would sooner believe that two Yankee professors lied, than th.docxI would sooner believe that two Yankee professors lied, than th.docx
I would sooner believe that two Yankee professors lied, than th.docx
 
I wrote my paper and my feed back was- This is supposed to be a prof.docx
I wrote my paper and my feed back was- This is supposed to be a prof.docxI wrote my paper and my feed back was- This is supposed to be a prof.docx
I wrote my paper and my feed back was- This is supposed to be a prof.docx
 
I would like to discuss my experience developing and implementing .docx
I would like to discuss my experience developing and implementing .docxI would like to discuss my experience developing and implementing .docx
I would like to discuss my experience developing and implementing .docx
 
I would do it myself, but I have been taking care of my sick child. .docx
I would do it myself, but I have been taking care of my sick child. .docxI would do it myself, but I have been taking care of my sick child. .docx
I would do it myself, but I have been taking care of my sick child. .docx
 
I would have to identify the character Desiree.  I chose Desiree for.docx
I would have to identify the character Desiree.  I chose Desiree for.docxI would have to identify the character Desiree.  I chose Desiree for.docx
I would have to identify the character Desiree.  I chose Desiree for.docx
 
I would appreciate your help on this!Prepare a version of Final .docx
I would appreciate your help on this!Prepare a version of Final .docxI would appreciate your help on this!Prepare a version of Final .docx
I would appreciate your help on this!Prepare a version of Final .docx
 
I will give you an example of the outline paper from my teacherI.docx
I will give you an example of the outline paper from my teacherI.docxI will give you an example of the outline paper from my teacherI.docx
I will give you an example of the outline paper from my teacherI.docx
 

Recently uploaded

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

Student Lab Activity CIS170 Week 6 Lab Instructions.docx

  • 1. Student Lab Activity CIS170 Week 6 Lab Instructions Lab 7 of 7: Sequential Files Lab Overview—Scenario/Summary You will code, build, and execute a program that requires sequential files to create an address database. Learning Outcomes 1. Continue using a menu system with console applications. 2. Be able to write a console application. 3. Demonstrate entering, appending, storing, and retrieving records. 4. Be able to write lines of output to a text file in order to create a report. Deliverables Section Deliverable Points Lab Program Listing and Output 40 All Steps
  • 2. Total 40 Lab Steps Preparation: If you are using the Citrix remote lab, follow the login instructions located in the lab area in Course Home. Locate the Visual Studio icon and launch the application. Lab: Step 1: Requirements: An Address Database Create a C++ console application that will store and retrieve names and addresses in a text file. The program should do the following. 1. It should accept a series of names and addresses from the console. 2. The user's input should be written to a text file in the CSV format described in the lesson, but do not include the field names in the first row of the file. Use a delimiter to separate the records. 3. Read the records from the text file, and display them in a user-friendly format. 4. Provide a menu to allow the user to append records to the file, display the records, or exit the application. Build upon the code below to complete the assignment. //Specification: Append and display records in a address database #include <iostream> #include <fstream> #include <string> using namespace std; void menu(void);
  • 3. void writeData(void); void readData(void); const char FileName[] = "TestAddress.txt"; int main () { menu(); return 0; } //end main void menu(void) { //allow user to choose to append records, display records or exit the program }//end menu void writeData(void){ //Write the Address Info to a file //loop while user still has data to write to file //eg outStream<<name<<”#”; //where # is the delimiter }//end write data void readData(void){ //read data from a file //use the split function to break a //deliminated line of text into fields ifstream inMyStream (FileName); if (inMyStream.is_open()) { //set character to use as a line between record displays string recBreaks = ""; recBreaks.assign(20,'-'); int fieldCount = 0; //keep track of the number of fields read int recordCount = 1; //keep track of the number of records read
  • 4. //read the first field fieldCount = 1; string fieldBuffer; getline (inMyStream, fieldBuffer, '#'); while (!inMyStream.eof() ){ //display the field switch (fieldCount) { case 1: cout << recBreaks << endl; cout << "record # " << recordCount << endl; cout << "Name...." << fieldBuffer << endl; break; case 2: cout << "Street.." << fieldBuffer << endl; break; case 3: cout << "City...." << fieldBuffer << endl; break; case 4: cout << "State..." << fieldBuffer << endl; break; case 5: cout << "Zip....." << fieldBuffer << endl; fieldCount = 0; recordCount++; break; } //read the next field getline (inMyStream, fieldBuffer, '#'); fieldCount++;
  • 5. } cout << recBreaks << endl; inMyStream.close(); }//end read data Step 2: Processing Logic Using the pseudocode below, write the code that will meet the requirements. The pseudocode for the writeData function is shown below. Start open the text file to append start do while loop Allow user to enter name store name (using getline method) Allow user to enter city store city (using getline method) . . write name, city, etc. to the file end loop close the file End The program input should appear similar to this. Append Records Name..........John Smith Street.........902 Union Ave City............Any Town State...........TX Zip Code......78552 "Enter another Record? (Y/N) "
  • 6. The file structure should look like this. John Smith, 902 Union Ave, Any Town, TX, 79552 Eric Jones, 345 State Way, Fresno, CA, 93432 ... The file output should appear similar to the following. Show Records __________________________________________ Record #1 Name...........John Smith Street..........902 Union Ave City.............Any Town State...........TX Zip Code......78552 __________________________________________ Record #2 Name...........Eric Jones Street..........345 State Way City.............Fresno State...........CA Zip Code.......93432 __________________________________________ (A)ppend Records, (S)how Records, (E)xit Step 3: Create a New Project Create a new project and name it LAB7. Write your code using the processing logic in Step 2. Make sure you save your program. Step 4: Compile and Execute a) Compile your program. Eliminate all the syntax errors. b) Build your program and verify the results of the program. Make corrections to the program logic, if necessary, until the results of the program execution are what you expect.
  • 7. Step 5: Print Screenshots and Program 1. Capture a screen print of your output. (Do a print screen and paste into an MS Word document.) 2. Copy your code and paste it into the same MS Word document that contains the screen print of your output. 3. Save the Word document as Lab07_LastName_FirstInitial. END OF LAB Version 1.0 Page 1 of 9 4/9/2009 Lab Activity CIS CIS170B-A1.docx Page 1 of 5 Lab Activity CIS CIS170C-A7