Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Author: Zachariah Myers
- * Date Created: 11/30/15
- * Lab Number: CST 116 11.14 Programming Exercise #4
- * Filename: 11.14 Exercise 4.cpp
- *
- * Overview: This program contains a database of information sorted by persons.
- * It displays a menu with options for users to find information, add information
- * to the database, edit information in the database, and display all records in
- * the database.
- *
- * Input: This program recieves data from a database file, as well as allowing users to input
- * a choice at the main menu and add or edit information in the database.
- *
- * Output: If a display option is selected, this program will display either one person's information
- * or the information of every person in the database.
- */
- #include<iostream>
- #include<fstream>
- using std::cin;
- using std::cout;
- using std::endl;
- using std::ifstream;
- using std::ofstream;
- //void findPerson();
- void addNewPerson(char FirstName[], char LastName[], char PhoneNum[], char BirthDate[]);
- //void editPerson();
- //void displayAll();
- const int NAMELEN = 81;
- const int NUMLEN = 12;
- int main() {
- int choice; //variable for menu choice
- //main menu
- cout << "\t--MainMenu--\n" << endl;
- cout << "1. Find a person's information" << endl;
- cout << "2. Add a person to the database" << endl;
- cout << "3. Edit a person's information" << endl;
- cout << "4. Display every person's information" << endl;
- cout << "5. Quit\n" << endl;
- cout << "\tPlease choose an option: ";
- cin >> choice;
- //switch for user's choice at main menu
- switch (choice) {
- //find info choice
- case 1: {
- }
- break;
- //add person choice
- case 2:
- char FirstName[NAMELEN]; //array for holding first name
- char LastName[NAMELEN]; //array for holding last name
- char PhoneNum[NUMLEN]; //array for holding phone number
- char BirthDate[NUMLEN]; //array for holding date of birth
- //asks for names, ph #, and bday, then stores them in arrays
- cout << "\nPlease enter a first name: ";
- cin >> FirstName;
- cout << "\nPlease enter a last name: ";
- cin >> LastName;
- cout << "\nPlease enter a phone number in format ###-###-####: ";
- cin >> PhoneNum;
- cout << "\nPlease enter a birth date in format MM-DD-YY: ";
- cin >> BirthDate;
- addNewPerson(FirstName, LastName, PhoneNum, BirthDate);
- break;
- //edit person choice
- case 3: {
- }
- break;
- //display everyone choice
- case 4: {
- }
- break;
- //quite choice
- case 5: {
- }
- break;
- //default (invalid input)
- default:
- cout << "\nInvalid Input!" << endl;
- break;
- }
- system("pause");
- return 0;
- }
- void addNewPerson(char First, char Last, char Phone, char Birth) {
- //creates database object and opens database text file
- ofstream database;
- database.open("database.txt", std::ios_base::app);
- database << Last << First << Phone << Birth;
- database.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement