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 ā¦
CIS170C Lab Report Template/
(1) Code
// —————————————————————
// Programming Assignment: LAB1A // Developer:
// Date Written: 12/11/2020
// Purpose: Store and retrieve names and addresses in a
// sequential text file in CSV format.
// —————————————————————
#include < iostream >
#include < fstream >
#include < string > #include < iomanip > using namespace std;
void EnterAndWriteAddresses(void) ; void ReadAndDisplayAddresses(void) ; const string ADDRESS_FILE_NAME = “NameAddress.csv”;
int main()
{ int choice;
cout << “Address Record Application” << endl << endl; do
{ cout << “Please choose one of the following options: " << endl; cout << “1) Enter new address records” << endl; cout << “2) Display address records” << endl; cout << “3) Exit the program” << endl; cout << “Enter choice: “; cin » choice; if (choice == 1)
{
EnterAndWriteAddresses();
}
else if (choice == 2)
{
ReadAndDisplayAddresses();
}
else if (choice != 3)
{ cout << “Invalid choice —- please enter 1, 2 or 3” << endl;
}
cout << endl;
}
while (choice != 3);
cout << “Thank you for using the Address Record Application.” << endl; system(“pause”) ;
}
void EnterAndWriteAddresses(void)
{ string name, street, city, state, zip; char choice;
ofstream fout(ADDRESS_FILE_NAME, std::ofstream:: app); do
{ cin.ignore(100, ‘\n’) ; cout << endl << “Name: “; getline(cin, name); cout << “Street Address: “; getline(cin, street); cout << “City: “; getline(cin, city); cout << “State: “; getline(cin, state); cout << “Zip Code: “; getline(cin, zip);
fout << name << “,” << street << “,” << city << “,” << state << “,” <<
zip; cout << “Enter another address (Y/N)? “; cin » choice;
if (choice == ‘y’ || choice == ‘Y’) fout << endl;
}
while (choice == ‘y’ || choice == ‘Y’) ; fout.close();
}
void ReadAndDisplayAddresses(void)
{ string name, street, city, state, zip; ifstream inputAddress(ADDRESS_FILE_NAME);
if (inputAddress.is_open())
{ while (getline(inputAddress, name, ‘,'))
{ getline(inputAddress, street, ‘,') ; getline(inputAddress, city, ‘,') ; getline(inputAddress, state, ‘,') ; getline(inputAddress, zip, ‘\n’) ;
cout << endl << left << setw(20) << “Name: " << name << endl; cout << left << setw(20) << “Street address: " << street << endl;
cout << left << setw(20) << “City: " << city << endl; cout << left << setw(20) << “State: " << state << endl; cout << left << setw(20) << “Zip Code: " << zip << endl;
}
inputAddress.close(); }
}
(2) Screenshot
Powered by TCPDF (www.tcpdf.org)
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: ā¦