0% found this document useful (0 votes)
6 views36 pages

Codemo4 Title

The document is a C++ program for a hotel reservation system that allows users to book hotel rooms, view, change, and cancel their bookings. It includes data structures for guests and hotel bookings, functions for managing bookings, and a simple text-based user interface. The program validates user input for guest details, room selection, and booking dates, and it calculates total prices based on room types and stay duration.

Uploaded by

tojizeninn12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views36 pages

Codemo4 Title

The document is a C++ program for a hotel reservation system that allows users to book hotel rooms, view, change, and cancel their bookings. It includes data structures for guests and hotel bookings, functions for managing bookings, and a simple text-based user interface. The program validates user input for guest details, room selection, and booking dates, and it calculates total prices based on room types and stay duration.

Uploaded by

tojizeninn12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <iostream>

#include <string>

#include <fstream>

#include <vector>

#include <stack>

#include <list>

#include <algorithm>

#include <sstream>

#include <cctype>

#include <limits>

#include <iomanip>

using namespace std;

#define RESET "\033[0m"

#define RED "\033[31m"

#define GREEN "\033[32m"

#define YELLOW "\033[33m"

#define CYAN "\033[36m"

#define WHITE "\033[97m"

#define BOLD "\033[1m"

struct Guest {

string name;

int age;

string gender;

string contactNumber;

};
struct HotelBooking {

Guest guest;

string hotelLocation;

string roomType;

string roomNumber;

string checkInDate;

string checkOutDate;

double totalPrice;

double roomPrice;

int stayDuration;

bool operator==(const HotelBooking &other) const {

return [Link] == [Link] &&

[Link] == [Link] &&

[Link] == [Link] &&

[Link] == [Link] &&

hotelLocation == [Link] &&

roomType == [Link] &&

roomNumber == [Link] &&

checkInDate == [Link] &&

checkOutDate == [Link];

};

stack<HotelBooking> bookingHistory;

list<HotelBooking> bookingsList;

const int ROOMS = 40;


string availableRooms[ROOMS] = {

"R101", "R102", "R103", "R104", "R105",

"R106", "R107", "R108", "R109", "R110",

"R111", "R112", "R113", "R114","R115",

"R116", "R117", "R118", "R119", "R120",

"R121", "R122", "R123", "R124", "R125",

"R126", "R127", "R128", "R129", "R130",

"R131", "R132", "R133", "R134","R135",

"R136", "R137", "R138", "R139", "R140"

};

string roomTypes[3] = {"Single", "Double", "Suite"};

const double basePrices[3] =

{3000.00, 5000.00, 7000.00};

struct Payment {

double gcashBalance = 20000.00;

double paymayaBalance = 20000.00;

double paypalBalance = 20000.00;

};

void showMainMenu();

void bookHotel();

void viewBookings();

void changeBooking();

void cancelBooking();

void assignRoomSchedule(HotelBooking& booking);

double calculatePrice(const string &roomType, int hotelIndex);


bool isValidContactNumber(const string &contactNumber);

bool isValidName(const string& name);

void loadBookingsFromFile();

void processPayment(double totalPrice);

bool isValidDate(const string& date);

int calculateDaysBetween(const string& startDate, const string& endDate);

int main() {

loadBookingsFromFile();

showMainMenu();

return 0;

void showMainMenu() {

int choice;

do {

system("cls");

cout << BOLD << WHITE;

cout << "\t \t \t|================ HOTEL RESERVATION SYSTEM =================|" << RESET
<< endl;

cout << "\t \t \t|\t1. Book a Hotel Room |" << endl;

cout << "\t \t \t|\t2. View My Bookings |" << endl;

cout << "\t \t \t|\t3. Change My Booking |" << endl;

cout << "\t \t \t|\t4. Cancel My Booking |" << endl;

cout << "\t \t \t|\t5. Exit |" << endl;

cout << "\t \t \t|===========================================================|" << endl;

cout << GREEN"\t \t \tPlease enter your choice (1-5): "<< RESET ;

cin >> choice;


[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

switch (choice) {

case 1:

bookHotel();

break;

case 2:

viewBookings();

break;

case 3:

changeBooking();

break;

case 4:

cancelBooking();

break;

case 5:

cout << "Exiting the system. Thank you!\n";

break;

default:

cout << RED << "Invalid choice. Please try again.\n" << RESET;

if (choice != 5) {

cout << YELLOW << "Press Enter to continue..." << RESET;

[Link]();

[Link]();

}
} while (choice != 5);

void bookHotel() {

system("cls");

HotelBooking booking;

cout << "\t \t \t|===========================================================|" << endl;

cout << WHITE << "\t \t \t|================ ADDING HOTEL RESERVATION =================|"
<< RESET << endl;

cout << "\t \t \t|===========================================================|" << endl;

while (true) {

cout << GREEN << "\n\t \t Enter your name (First Name Last Name): " << RESET;

[Link]();

getline(cin, [Link]);

if (isValidName([Link])) {

break;

} else {

cout << RED << "\t \t Invalid input. Please enter a valid name.\n" << RESET << endl;

cout << GREEN << "\t \t Enter your age (18 or older): " << RESET;

while (true) {

cin >> [Link];

if ([Link]() || [Link] < 18) {


[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Please enter a valid age (18 or older): " << RESET;

} else {

break;

cout << GREEN << "\t \t Enter your gender (Male 'M', Female 'F'): " << RESET;

while (true) {

cin >> [Link];

[Link](numeric_limits<streamsize>::max(), '\n');

if ([Link] == "M" || [Link] == "F" ||

[Link] == "m" || [Link] == "f") {

[Link] = toupper([Link][0]);

break;

} else {

[Link]();

cout << RED << "\t \t Please enter 'M' for Male or 'F' for Female: " << RESET;

cout << GREEN << "\t \t Enter your contact number (11 digits starting with '09'): " << RESET;

while (true) {

cin >> [Link];

if (isValidContactNumber([Link])) {

break;

} else {
cout << RED << "\t \t Must be exactly 11 digits and start with '09': " << RESET;

cout << GREEN << "\n\t \t Available Rooms: \n" << RESET;

cout << "\t \t |


=====================================================================================
==============|" << endl;

for (int i = 0; i < ROOMS; i++) {

if (availableRooms[i] == "") {

cout << YELLOW << "\t \t ____" << "\t" << RESET;

} else {

cout << YELLOW << "\t \t " << availableRooms[i] << "\t" << RESET;

if ((i + 1) % 5 == 0) {

cout << endl;

cout << "\t \t |


=====================================================================================
==============|" << endl;

while (true) {

cout << GREEN << "\n \t \t Enter Room Number: " << RESET;

string inputRoomNumber;

cin >> inputRoomNumber;

transform([Link](), [Link](),
[Link](), ::toupper);
bool roomAvailable = false;

for (int i = 0; i < ROOMS; i++) {

if (availableRooms[i] == inputRoomNumber) {

roomAvailable = true;

availableRooms[i] = "";

[Link] = inputRoomNumber;

break;

if (roomAvailable) {

break;

} else {

cout << RED << "\t \t Room number not available. Please choose another room number.\n" <<
RESET;

if ([Link]()) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid input. Please enter a valid room number.\n" << RESET;

}
cout << "\n\t \t |
==================================================================================|"
<< endl;

cout << "\t \t | " << YELLOW << "1. Single = 3000 " << RESET

<< "\t \t | " << YELLOW << "2. Double = 5000 " << RESET

<< "\t \t | " << YELLOW << "3. Suite = 7000 " << RESET << " |" << endl;

cout << "\t \t |


==================================================================================|"
<< endl;

cout << GREEN << "\n\t \t Choose Room Type: " << RESET;

int roomTypeChoice;

while (true) {

cin >> roomTypeChoice;

if ([Link]() || roomTypeChoice < 1 || roomTypeChoice > 3) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid choice. Please choose a number between 1 and 3: " << RESET;

} else {

[Link] = roomTypes[roomTypeChoice - 1];

break;

assignRoomSchedule(booking);

double totalPrice = calculatePrice([Link], 0);

cout << GREEN << "Booking successful! Please proceed with payment.\n" << RESET << endl;
processPayment(totalPrice);

system("cls");

showMainMenu();

void assignRoomSchedule(HotelBooking& booking) {

while (true) {

cout << GREEN<< "\n \t \t Enter check-in date (DD/MM/YYYY): "<< RESET;

cin >> [Link];

if (isValidDate([Link])) {

break;

} else {

cout << RED << "\t \t Invalid date! Ensure format is DD/MM/YYYY and within 2024.\n" << RESET;

while (true) {

cout << GREEN<< "\t \t Enter check-out date (DD/MM/YYYY): "<< RESET;

cin >> [Link];

if (isValidDate([Link])) {

int stayDuration = calculateDaysBetween([Link], [Link]);

if (stayDuration > 0) {
[Link] = (stayDuration *500)+ calculatePrice ([Link], 0);

cout << GREEN << "\t \t Stay Duration: " << RESET<< stayDuration<<"Days";

cout << YELLOW << "\n \n \t \t The Total Price For Your Stay (" << [Link]

<< " room) is: " << RESET << fixed << setprecision(2) << [Link] << " PHP." << endl;

bookingsList.push_back(booking);

[Link](booking);

processPayment([Link]);

break;

} else {

cout << RED << "\t \t Check-out date must be after check-in date.\n" << RESET;

} else {

cout << RED << "\t \t Invalid date! Ensure format is DD/MM/YYYY and within 2024.\n" << RESET;

double calculatePrice(const string &roomType, int hotelIndex) {

double price = 0.0;

if (roomType == "Single") {

price = basePrices[0];

} else if (roomType == "Double") {

price = basePrices[1];

} else if (roomType == "Suite") {

price = basePrices[2];
}

return price;

bool bookingsLoaded = false;

void viewBookings() {

if (!bookingsLoaded) {

loadBookingsFromFile();

system("cls");

if ([Link]()) {

cout << RED << "No bookings found.\n" << RESET << endl;

} else {

cout << CYAN << "=== Your Bookings ===\n" << RESET;

for (const auto& booking : bookingsList) {

cout << GREEN << "Guest: " << [Link] << RESET << endl;

cout << "Location: " << "Nueva Ecija" << endl;

cout << "Room Type: " << [Link] << endl;

cout << "Room Number: " << [Link] << endl;

cout << "Check-in Date: " << [Link] << endl;

cout << "Check-out Date: " << [Link] << endl;

cout << "Price: " << "PHP: "<<[Link] << endl;

cout << "-----------------------------\n";

}
cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link]();

[Link]();

system("cls");

showMainMenu();

void changeBooking() {

system("cls");

if ([Link]()) {

cout << RED << "No bookings found to change.\n" << RESET << endl;

cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link]();

[Link]();

system("cls");

showMainMenu();

return;

} else {

int index = 0;

cout << CYAN << "=== Your Bookings ===\n" << RESET;

for (const auto& booking : bookingsList) {

cout << GREEN << "INDEX: " << index++ << RESET << endl;

cout << "Guest: " << [Link] << endl;

cout << "Room Type: " << [Link] << endl;

cout << "Room Number: " << [Link] << endl;

cout << "Check-in Date: " << [Link] << endl;

cout << "Check-out Date: " << [Link] << endl;


cout << "-----------------------------\n";

int bookingIndex;

cout << "Enter the index of the booking you want to change: ";

cin >> bookingIndex;

if ([Link]() || bookingIndex < 0 || bookingIndex >= [Link]()) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid index. Returning to main menu.\n" << RESET << endl;

cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link]();

[Link]();

system("cls");

showMainMenu();

return;

auto it = [Link]();

advance(it, bookingIndex);

HotelBooking& booking = *it;

system("cls");

cout << CYAN << "=== Your Bookings ===\n" << RESET;

cout << GREEN << "INDEX: " << bookingIndex << RESET << endl;

cout << "Guest: " << [Link] << endl;

cout << "Room Type: " << [Link] << endl;

cout << "Room Number: " << [Link] << endl;


cout << "Check-in Date: " << [Link] << endl;

cout << "Check-out Date: " << [Link] << endl;

cout << "-----------------------------\n";

cout << CYAN << "=== What would you like to change? ===\n" << RESET;

cout << "1. Guest Information\n";

cout << "2. Room Type\n";

cout << "3. Room Number\n";

cout << "4. Check-in Date / Check-out Date\n";

int choice;

bool validChoice = false;

while (!validChoice) {

cout << "Enter your choice (1-4): ";

cin >> choice;

if ([Link]() || choice < 1 || choice > 4) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid input. Please select a valid option (1-4).\n" << RESET;

} else {

validChoice = true;

switch (choice) {

case 1: {

char changeName;
cout << "\tCurrent Guest Name: " << [Link] << endl;

while (true) {

cout << "\tDo you want to change the guest name? (y/n): ";

cin >> changeName;

if (changeName == 'y' || changeName == 'Y' || changeName == 'n' || changeName == 'N') {

break;

} else {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

if (changeName == 'y' || changeName == 'Y') {

while (true) {

cout << "Enter new name: ";

[Link]();

getline(cin, [Link]);

if (isValidName([Link])) {

break;

} else {

cout << RED << "Invalid input. Please enter a valid name." << RESET << endl;

}
break;

case 2: {

char changeRoomType;

cout << "\tCurrent Room Type: " << [Link] << endl;

cout << "\tDo you want to change the room type? (y/n): ";

cin >> changeRoomType;

while (changeRoomType != 'y' && changeRoomType != 'Y' && changeRoomType != 'n' &&
changeRoomType != 'N') {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << "\tDo you want to change the room type? (y/n): ";

cin >> changeRoomType;

if (changeRoomType == 'y' || changeRoomType == 'Y') {

cout << "| " << YELLOW << "1. Single = 3000 " << RESET

<< "| " << YELLOW << "2. Double = 5000 " << RESET

<< "| " << YELLOW << "3. Suite = 7000 " << RESET << " |" << endl;

cout << GREEN << "\nChoose Room Type: " << RESET;

int roomTypeChoice;

while (true) {

cin >> roomTypeChoice;

if ([Link]() || roomTypeChoice < 1 || roomTypeChoice > 3) {

[Link]();
[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid choice. Please choose 1, 2, or 3: " << RESET;

} else {

string roomTypes[] = {"Single", "Double", "Suite"};

int roomPrices[] = {3000, 5000, 7000};

[Link] = roomTypes[roomTypeChoice - 1];

[Link] = roomPrices[roomTypeChoice - 1];

int stayDuration = calculateDaysBetween([Link], [Link]);

[Link] = stayDuration;

[Link] = (stayDuration * 500) + [Link];

cout << GREEN << "\tRoom Type updated to: " << [Link] << RESET << endl;

cout << YELLOW << "\tNew Total Price: " << RESET << [Link] << " PHP" << endl;

break;

break;

case 3: {

char changeRoom;

cout << "\tCurrent Room Number: " << [Link] << endl;

cout << "\tDo you want to change the room number? (y/n): ";

cin >> changeRoom;


while (changeRoom != 'y' && changeRoom != 'Y' && changeRoom != 'n' && changeRoom != 'N') {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

cout << "\tDo you want to change the room number? (y/n): ";

cin >> changeRoom;

if (changeRoom == 'y' || changeRoom == 'Y') {

cout << GREEN << "Available Rooms: \n" << RESET;

for (int i = 0; i < ROOMS; i++) {

if (availableRooms[i] == "") {

cout << "____" << "\t";

} else {

cout << YELLOW << availableRooms[i] << "\t" << RESET;

if ((i + 1) % 5 == 0) {

cout << endl;

cout << RESET << endl;

while (true) {

cout << GREEN << "Enter new room number: " << RESET;

string newRoomNumber;

cin >> newRoomNumber;


transform([Link](), [Link](), [Link](), ::toupper);

bool roomAvailable = false;

for (int i = 0; i < ROOMS; i++) {

if (availableRooms[i] == newRoomNumber) {

roomAvailable = true;

availableRooms[i] = "";

for (int j = 0; j < ROOMS; j++) {

if ("R" + to_string(j + 101) == [Link]) {

availableRooms[j] = [Link];

break;

[Link] = newRoomNumber;

break;

if (roomAvailable) {

break;

} else {

cout << RED << "Room number not available. Please choose another room number.\n" << RESET;

}
break;

case 4: {

char changeDates;

cout << "\tCurrent Check-in Date: " << [Link] << endl;

cout << "\tCurrent Check-out Date: " << [Link] << endl;

cout << "\tDo you want to change the check-in and check-out dates? (y/n): ";

cin >> changeDates;

while (changeDates != 'y' && changeDates != 'Y' && changeDates != 'n' && changeDates != 'N') {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

cout << "\tDo you want to change the check-in and check-out dates? (y/n): ";

cin >> changeDates;

if (changeDates == 'y' || changeDates == 'Y') {

while (true) {

cout << "\tEnter new check-in date (DD/MM/YYYY): ";

cin >> [Link];

if (isValidDate([Link])) {

break;

} else {

cout << RED << "\tInvalid date! Ensure format is DD/MM/YYYY and within 2024.\n" << RESET;

}
while (true) {

cout << "\tEnter new check-out date (DD/MM/YYYY): ";

cin >> [Link];

if (isValidDate([Link])) {

int stayDuration = calculateDaysBetween([Link], [Link]);

if (stayDuration > 0) {

[Link] = stayDuration;

[Link] = (stayDuration * 500) + [Link];

cout << GREEN << "\tStay duration updated to: " << RESET << stayDuration << " days.\n";

cout << YELLOW << "\nThe new total price for your stay (" << [Link]

<< " room) is: " << RESET << fixed << setprecision(2) << [Link] << " PHP.\n";

break;

} else {

cout << RED << "\tCheck-out date must be after check-in date.\n" << RESET;

} else {

cout << RED << "\tInvalid date! Ensure format is DD/MM/YYYY and within 2024.\n" << RESET;

break;

default:

break;
}

if ([Link] > 20000) {

double balanceDue = [Link] - 20000;

cout << RED << "\nTotal Price exceeds 20,000 PHP!\n" << RESET;

cout << GREEN << "You only have 20,000 PHP covered.\n" << RESET;

cout << YELLOW << "Please pay the remaining " << balanceDue << " PHP at the counter.\n" <<
RESET;

cout << GREEN << "\nBooking updated successfully!\n" << RESET;

cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link]();

[Link]();

system("cls");

showMainMenu();

void cancelBooking() {

system("cls");

if ([Link]()) {

cout << RED << "No bookings found to cancel.\n" << RESET << endl;

} else {

int index = 0;

cout << CYAN << "=== Your Bookings ===\n" << RESET;

for (const auto& booking : bookingsList) {


cout << GREEN << "INDEX: " << index++ << RESET << endl;

cout << "Guest: " << [Link] << endl;

cout << "Room Type: " << [Link] << endl;

cout << "Room Number: " << [Link] << endl;

cout << "Check-in Date: " << [Link] << endl;

cout << "Check-out Date: " << [Link] << endl;

cout << "Price: " << "PHP: "<<[Link] << endl;

cout << "-----------------------------\n";

int bookingIndex;

cout << "\tEnter the index of the booking you want to cancel: ";

cin >> bookingIndex;

if ([Link]() || bookingIndex < 0 || bookingIndex >= [Link]()) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid index. Returning to main menu.\n" << RESET << endl;

cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link]();

[Link]();

system("cls");

showMainMenu();

return;

auto it = [Link]();

advance(it, bookingIndex);
char confirm;

cout << "\tAre you sure you want to cancel the booking for " << it->[Link]<< "? (y/n): ";

cin >> confirm;

while (confirm != 'y' && confirm != 'Y' && confirm!= 'n' && confirm != 'N') {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

cout << "\tAre you sure you want to cancel the booking for " << it->[Link]<< "? (y/n): ";

cin >>confirm;

if (confirm == 'y' || confirm == 'Y') {

[Link](it);

cout << GREEN << "\tBooking cancelled successfully!\n" << RESET << endl;

} else {

cout << YELLOW << "\tCancellation aborted. Returning to main menu.\n" << RESET << endl;

cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link]();

[Link]();

system("cls");

showMainMenu();

void loadBookingsFromFile() {

ifstream file("[Link]");
if (file.is_open()) {

HotelBooking booking;

while (file >> [Link] >> [Link] >> [Link]

>> [Link] >> [Link] >> [Link]

>> [Link] >> [Link] >>


[Link]>>[Link]) {

bookingsList.push_back(booking);

[Link](booking);

for (int i = 0; i < ROOMS; i++) {

if (availableRooms[i] == [Link]) {

availableRooms[i] = "";

break;

[Link]();

bookingsLoaded = true;

} else {

cout << RED << "Error loading bookings from file.\n" << RESET << endl;

void processPayment(double totalPrice) {

Payment paymentMethods;

int paymentOption;

cout<< WHITE;

cout << "\t \t \t|================ PAYMENT OPTIONS =========================|" << endl;


cout << "\t \t \t| 1. GCash |" << endl;

cout << "\t \t \t| 2. PayMaya |" << endl;

cout << "\t \t \t| 3. PayPal |" << endl;

cout << "\t \t \t| 4. Pay at the Counter |" << endl;

cout << "\t \t \t|==========================================================|" << endl;

cout<< RESET;

cout << YELLOW<< "\t \t \tTotal Amount Due: " << fixed << setprecision(2) << totalPrice << " PHP\n"<<
RESET;

while (true) {

cout << "\t \t Please select your payment method (1-4): ";

cin >> paymentOption;

if ([Link]() || paymentOption < 1 || paymentOption > 4) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid choice. Please enter a valid option (1-4).\n" << RESET;

continue;

char confirm;

switch (paymentOption) {

case 1:

cout << YELLOW<< "\n\t \t You selected GCash.\n";

cout << "\t \t Current GCash balance: " << fixed << setprecision(2) <<
[Link] << " PHP\n"<< RESET;

do {

cout << GREEN<< "\t \t Are you sure you want to proceed with the payment of "<< RESET<<
YELLOW

<< fixed << setprecision(2) << totalPrice << " PHP"<< RESET<< GREEN<<"? (y/n): "<< RESET;
cin >> confirm;

if ([Link]() || (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N')) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

} while (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N');

if (confirm == 'y' || confirm == 'Y') {

if ([Link] >= totalPrice) {

[Link] -= totalPrice;

cout << "\n \t \t Payment Procesing.................";

cout << GREEN << "\n \n \t \t Payment successful! Remaining GCash balance: "<< RESET

<< YELLOW<< fixed << setprecision(2) << [Link] << " PHP.\n"
<< RESET;

break;

} else {

cout << RED << "\t \t You don't have enough balance in your GCash account.\n" << RESET;

} else {

cout << RED << "\t \t Payment not confirmed. Please select another option.\n" << RESET;

continue;

break;

case 2:

cout << YELLOW<< "\t \t You selected PayMaya.\n";

cout << "\t \t Current PayMaya balance: " << fixed << setprecision(2) <<
[Link] << " PHP\n"<< RESET;
do {

cout << GREEN<< "\t \t Are you sure you want to proceed with the payment of "<< RESET<<
YELLOW

<< fixed << setprecision(2) << totalPrice << " PHP"<< RESET<< GREEN<<"? (y/n): "<< RESET;

cin >> confirm;

if ([Link]() || (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N')) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

} while (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N');

if (confirm == 'y' || confirm == 'Y') {

if ([Link] >= totalPrice) {

[Link] -= totalPrice;

cout << "\n \t \t Payment Procesing.................";

cout << GREEN << "\n \t \t Payment successful! Remaining PayMaya balance: "<< RESET<<
YELLOW

<< fixed << setprecision(2) << [Link] << " PHP.\n" << RESET;

break;

} else {

cout << RED << "\t \t You don't have enough balance in your PayMaya account.\n" <<
RESET;

} else {

cout << RED << "\t \t Payment not confirmed. Please select another option.\n" << RESET;

continue;

break;
case 3:

cout << YELLOW<< "\t \t You selected PayPal.\n";

cout << "\t \t Current PayPal balance: " << fixed << setprecision(2) <<
[Link] << " PHP\n"<< RESET;

do {

cout<< GREEN << "\t \t Are you sure you want to proceed with the payment of "<< RESET<<
YELLOW

<< fixed << setprecision(2) << totalPrice << " PHP"<< RESET<< GREEN<<"? (y/n): "<< RESET;

cin >> confirm;

if ([Link]() || (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N')) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

} while (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N');

if (confirm == 'y' || confirm == 'Y') {

if ([Link] >= totalPrice) {

[Link] -= totalPrice;

cout << "\n \t \t Payment Procesing.................";

cout << GREEN << "\n \t \t Payment successful! Remaining PayPal balance: "<< RESET<<
YELLOW

<< fixed << setprecision(2) << [Link] << " PHP.\n" << RESET;

break;

} else {

cout << RED << "\t \t You don't have enough balance in your PayPal account.\n" << RESET;

} else {

cout << RED << "\t \t Payment not confirmed. Please select another option.\n" << RESET;

continue;
}

break;

case 4:

cout << YELLOW<< "\t \t You selected Pay at the Counter. Proceeding with payment...\n"<<
RESET;

do {

cout << GREEN<< "\t \t Are you sure you want to proceed with Pay at the Counter? (y/n): "<<
RESET;

cin >> confirm;

if ([Link]() || (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N')) {

[Link]();

[Link](numeric_limits<streamsize>::max(), '\n');

cout << RED << "\t \t Invalid choice. Please enter 'y' or 'n'.\n" << RESET;

} while (confirm != 'y' && confirm != 'Y' && confirm != 'n' && confirm != 'N');

if (confirm == 'y' || confirm == 'Y') {

cout << "\n \t \t Payment Procesing.................";

cout << GREEN << "\n \t \t Payment successful! No balance change for this option.\n" <<
RESET;

break;

} else {

cout << RED << "\t \t Payment not confirmed. Please select another option.\n" << RESET;

continue;

break;

}
cout << YELLOW << "\nPress Enter to return to the main menu..." << RESET;

[Link](numeric_limits<streamsize>::max(), '\n');

[Link]();

showMainMenu();

return;

bool isValidDate(const string& date) {

if ([Link]() != 10 || date[2] != '/' || date[5] != '/') {

return false;

int day = stoi([Link](0, 2));

int month = stoi([Link](3, 2));

int year = stoi([Link](6, 4));

if (year != 2024 || month < 1 || month > 12 || day < 1 || day > 31) {

return false;

if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) {

return false;

if (month == 2 && day > 29) {


return false;

return true;

};

int calculateDaysBetween(const string& startDate, const string& endDate) {

int startDay = stoi([Link](0, 2));

int startMonth = stoi([Link](3, 2));

int startYear = stoi([Link](6, 4));

int endDay = stoi([Link](0, 2));

int endMonth = stoi([Link](3, 2));

int endYear = stoi([Link](6, 4));

int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

if (startYear == 2024) daysInMonth[1] = 29;

int startTotalDays = startDay;

for (int i = 0; i < startMonth - 1; i++) {

startTotalDays += daysInMonth[i];

int endTotalDays = endDay;

for (int i = 0; i < endMonth - 1; i++) {

endTotalDays += daysInMonth[i];

return endTotalDays - startTotalDays;

};
bool isValidContactNumber(const string &contactNumber) {

if ([Link]() != 11) return false;

if ([Link](0, 2) != "09") return false;

for (char c : contactNumber) {

if (!isdigit(c)) return false;

return true;

bool isValidName(const string& name) {

if ([Link]()) return false;

bool hasValidCharacter = false;

size_t spaceCount = 0;

bool firstNameValid = false;

if (name[0] == ' ') return false;

for (size_t i = 0; i < [Link](); ++i) {

char ch = name[i];

if (isalpha(ch) || ch == '-') {

hasValidCharacter = true;

spaceCount = 0;

if (spaceCount == 0 && !firstNameValid) {

firstNameValid = true;

}
else if (ch == ' ') {

spaceCount++;

if (spaceCount > 1) {

return false;

} else {

return false;

return hasValidCharacter;

You might also like