Professional Documents
Culture Documents
Lab7 3
Lab7 3
Lab7 3
h"
void NOTE::input_data()
{
fullName = new char[50];
phoneNumber = new char[20];
cin.ignore();
cout << "Enter full name: ";
cin.getline(fullName, 50);
}
}
void addNotes(NOTE* notes, int& numNotes) {
int numToAdd;
cout << "Enter the number of notes you want to add: ";
cin >> numToAdd;
numNotes += numToAdd;
}
void NOTE::show_data()
{
cout << "Full name" << fullName << ", phone number:" << phoneNumber << ",
Birth date: " << birthDate[0] << "-" << birthDate[1] << "-" << birthDate[2] <<
endl;
}
void showPeople( NOTE* notes, int numNotes)
{
cout << "All people: " << endl;
for (int i = 0; i < numNotes; i++)
{
notes[i].show_data();
}
}
cout << "People with the surname '" << searchSurname << "':\n";
for (int i = 0; i < numNotes; ++i) {
char* lastName = strrchr(notes[i].fullName, ' ');
if (lastName && strcmp(lastName + 1, searchSurname) == 0) {
cout << "Full Name: " << notes[i].fullName << ", Phone Number: "
<< notes[i].phoneNumber << ", Birth Date: "
<< notes[i].birthDate[0] << "-" << notes[i].birthDate[1] <<
"-" << notes[i].birthDate[2] << endl;
found = true;
}
}
if (!found) {
cout << "No people found with the surname '" << searchSurname << "'.\
n";
}
}
if (!found) {
cout << "No person found with the provided phone number." << endl;
}
}
if (!found) {
cout << "No people found with birthdays in the provided month." <<
endl;
}
}
#pragma once
#include <iostream>
#include<iomanip>
using namespace std;
struct NOTE {
char* fullName;
char* phoneNumber;
int birthDate[3];
void input_data();
void show_data();
};
void SortBySurname(NOTE* , int );
void SortByBirthDate(NOTE*, int);
void searchBySurname(NOTE* , int);
void searchByPhoneNumber(NOTE* , int );
void displayByBirthMonth(NOTE*, int );
void showPeople( NOTE*, int);
void addNotes(NOTE*, int&);
#include<iostream>
#include"Struct.h"
#include"voids.h"
using namespace std;
int main() {
NOTE notes[100];
int numNotes = 0;
int choice;
do {
cout << "\n1. Add Notes\n2. Sort Notes by Name\n3. Sort Notes by Birth
Date\n4. Search by Name\n5. Search by Phone Number\n6. Display People by Birth
Month\n7. Show all notes\n0. Exit\nEnter your choice: ";
cin >> choice;
switch (choice) {
case 1:
addNotes(notes, numNotes);
break;
case 2:
SortBySurname(notes, numNotes);
cout << "Notes sorted by Full Name." << endl;
break;
case 3:
SortByBirthDate(notes, numNotes);
cout << "Notes sorted by Date of Birth." <<endl;
break;
case 4:
searchBySurname(notes, numNotes);
break;
case 5:
searchByPhoneNumber(notes, numNotes);
break;
case 6:
displayByBirthMonth(notes, numNotes);
break;
case 7:
showPeople(notes, numNotes);
break;
case 8:
cout << "Exiting the program. Goodbye!" << endl;
break;
default:
cout << "Invalid choice." << endl;
break;
}
} while (choice != 0);
system("pause");
return 0;
}