NTR 100 COMPLETE Syllabus and Academic Integrity Acknowledgement Arizona State University
NTR 100 COMPLETE Syllabus and Academic Integrity Acknowledgement Question 1 1 / 1 pts I have read the ASU ā¦
Student Lab Activity
Ā
A.Ā Ā Ā Lab # CIS CIS170C-A7Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā
B.Ā Ā Ā Lab 7 of 7:Sequential Files
Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā
C.Ā Ā Ā Lab Overview - Scenario/Summary
Ā
You will code, build, and execute a program that requiressequential files to create an address database.
Ā
Learning Outcomes
Ā
Ā
D.Ā Ā Ā Deliverables
Ā
Section
Deliverable
Points
Step
Program Listing and Output
45
Ā
Ā
E.Ā Ā Ā Lab Steps
Ā
Preparation:
Ā
If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.
Ā
Locate the Visual Studio 2010 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.
Build upon the code below to complete the assignment.
//Specification: Append and display records in a address database
#include<iostream> #include<fstream> #include<string>
usingnamespaceĀ std;
voidĀ menu(void); voidĀ writeData(void); voidĀ readData(void); string * split(string,Ā char);
constcharĀ 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
}//end write data
voidĀ readData(void){ //read data from a file //use the split function to break a //deliminated line of text into fields
}//end read data
string * split(string theLine,Ā charĀ theDeliminator){ Ā Ā Ā Ā Ā Ā Ā Ā //Break theline into fields and save the fields to an array. Ā Ā Ā Ā Ā Ā Ā //Each field will occupy one element in a character array. Ā Ā Ā Ā Ā Ā Ā //theLine is a string with fields separated with theDeliminator character. Ā Ā Ā Ā Ā Ā Ā //Assumes the last field in the string is terminated with a newline. Ā Ā Ā Ā Ā Ā Ā //Useage: string *theFields = split(lineBuffer, ‘,');
Ā Ā Ā Ā Ā Ā Ā //determine how many splits there will be so we can size our array Ā Ā Ā Ā Ā Ā Ā intĀ splitCount = 0; Ā Ā Ā Ā Ā Ā Ā Ā for(intĀ i = 0; i < theLine.size(); i++){ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā ifĀ (theLine[i] == theDeliminator) Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā splitCount++; Ā Ā Ā Ā Ā Ā Ā } Ā Ā Ā Ā Ā Ā Ā splitCount++;Ā //add one more to the count because there is not an ending comma
Ā Ā Ā Ā Ā Ā Ā //create an array to hold the fields Ā Ā Ā Ā Ā Ā Ā string* theFieldArray; Ā Ā Ā Ā Ā Ā Ā theFieldArray =Ā newĀ string[splitCount];
Ā Ā Ā Ā Ā Ā Ā //split the string into seperate fields Ā Ā Ā Ā Ā Ā Ā string theField =Ā “"; Ā Ā Ā Ā Ā Ā Ā Ā intĀ commaCount = 0;
Ā Ā Ā Ā Ā Ā Ā Ā for(intĀ i = 0; i < theLine.size(); i++){Ā //read each character and look for the deliminator Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā ifĀ (theLine[i] != theDeliminator) { Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā theField += theLine[i];Ā //build the field Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā } Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā elseĀ {Ā //the deliminator was hit so save to the field to the array Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā theFieldArray[commaCount] = theField;Ā //save the field to the array Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā theField =Ā “"; Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā commaCount++; Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā } Ā Ā Ā Ā Ā Ā Ā } Ā Ā Ā Ā Ā Ā Ā theFieldArray[commaCount] = theField;Ā //the last field is not marked with a comma…
Ā Ā Ā Ā Ā Ā Ā Ā returnĀ theFieldArray; }Ā //end split
Ā
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
NTR 100 COMPLETE Syllabus and Academic Integrity Acknowledgement Question 1 1 / 1 pts I have read the ASU ā¦
HEP 456 Module 6 Section 14 Communication and Dissemination of The Findings HEP 456: Health Promotion Program ā¦
HEP 456 Module 5 Section 12 and 13 Planning for Analysis and Interpretation and Gantt chartĀ Name HEP 456: ā¦