diff options
| author | Asahel <[email protected]> | 2024-02-12 18:03:30 -0800 |
|---|---|---|
| committer | Asahel <[email protected]> | 2024-02-12 18:03:30 -0800 |
| commit | 36c4160b5a2a4734eda79ac04d216f003c4b8368 (patch) | |
| tree | 9ee8308267f213daff33456875bddbdcbe7cad10 /Homework5 | |
| parent | Added new files. (diff) | |
| download | homework-5-asahellt-main.tar.xz homework-5-asahellt-main.zip | |
Diffstat (limited to 'Homework5')
| -rw-r--r-- | Homework5/Contacts.cpp | 41 | ||||
| -rw-r--r-- | Homework5/Contacts.h | 13 | ||||
| -rw-r--r-- | Homework5/program.cpp | 52 |
3 files changed, 98 insertions, 8 deletions
diff --git a/Homework5/Contacts.cpp b/Homework5/Contacts.cpp index e69de29..acde949 100644 --- a/Homework5/Contacts.cpp +++ b/Homework5/Contacts.cpp @@ -0,0 +1,41 @@ +#include "Contacts.h" +#include <iostream> + +using std::cout; +using std::endl; +using std::cin; + +Contact InputNewContact() { + Contact newContact = {}; + + cout << "Name: "; + cin >> newContact.Name; + + cout << "Email: "; + cin >> newContact.Email; + + cout << "Street Address: "; + cin >> newContact.StreetAddress; + + cout << "City: "; + cin >> newContact.City; + + cout << "State: "; + cin >> newContact.State; + + cout << "Zip: "; + cin >> newContact.Zip; + + return newContact; +} + +void PrintContacts(Contact(&contacts)[10]) { + for (auto &x : contacts) { + cout << "Name: " << x.Name << endl; + cout << "Email: " << x.Email << endl; + cout << "Street Address: " << x.StreetAddress << endl; + cout << "City: " << x.City << endl; + cout << "State: " << x.State << endl; + cout << "Zip: " << x.Zip << endl; + } +}
\ No newline at end of file diff --git a/Homework5/Contacts.h b/Homework5/Contacts.h index ba6bfcf..2336a71 100644 --- a/Homework5/Contacts.h +++ b/Homework5/Contacts.h @@ -1,6 +1,19 @@ #ifndef CONTACT_H #define CONTACT_H +struct Contact +{ + char Name[25] = {}; + char Email[100] = {}; + char StreetAddress[35] = {}; + char City[30] = {}; + char State[2] = {}; + int Zip = 0; +}; + +Contact InputNewContact(); + +void PrintContacts(Contact(&contacts)[10]); #endif // !CONTACT_H diff --git a/Homework5/program.cpp b/Homework5/program.cpp index f026a4b..c08993f 100644 --- a/Homework5/program.cpp +++ b/Homework5/program.cpp @@ -3,12 +3,48 @@ // Class: CST 116 // Assignment: Homework 5 -struct Contact +#include <iostream> +#include <cstdlib> +#include "Contacts.h" + +using std::cout; +using std::cin; +using std::endl; + +int main() { - char Namr[25] = {}; - char Email[100] = {}; - char StreetAddress[35] = {}; - char City[30] = {}; - char State[2] = {}; - int Zip = 0; -};
\ No newline at end of file + const int MAX = 10; + + Contact contacts[MAX] = {}; + int numberOfContacts = 0; + + char c = 'n'; + + do { + system("cls"); + cout << "1. Add New Contact\n"; + cout << "2. Update Contact\n"; + cout << "3. Print Contacts\n"; + cout << "Press 'x' to Exit\n\n"; + std::cin >> c; + switch (c) + { + case '1': + contacts[numberOfContacts++] = InputNewContact(); + break; + case '2': + + + break; + case '3': + break; + case 'x': + break; + default: + cout << "\nInvalid\n"; + } + + } while (c != 'x'); + + return 0; +}
\ No newline at end of file |