Data Structure and Algorithms
Source Code:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <ctime>
#include <iomanip>
#include <map>
#include <limits>
#include <cstdio> // For remove()
using namespace std;
// Structs for Order and Inventory
struct Order {
int orderID;
string customerName;
string pizzaType;
int quantity;
double totalPrice;
string paymentMethod;
string orderTime;
};
struct InventoryItem {
string ingredient;
int quantity;
};
// Inventory Management
map<string, int> inventory = {
{"cheese", 100},
{"dough", 100},
{"sauce", 100}
};
// Helper to get current time
string getCurrentTime() {
time_t now = time(0);
tm *ltm = localtime(&now);
char buffer[20];
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ltm);
return string(buffer);
// Update inventory
bool updateInventory(const string& ingredient, int quantityUsed) {
if (inventory[ingredient] >= quantityUsed) {
inventory[ingredient] -= quantityUsed;
return true;
return false;
// Process Order
void processOrder(int orderID, const string& customerName, const string& pizzaType, int quantity, double pricePerPizza,
const string& paymentMethod) {
double totalPrice = quantity * pricePerPizza;
// Check inventory
if (updateInventory("cheese", quantity) && updateInventory("dough", quantity) && updateInventory("sauce",
quantity)) {
string orderTime = getCurrentTime();
// Save order details to file
ofstream ordersFile("[Link]", ios::app);
if (!ordersFile.is_open()) {
cout << "Error: Could not open [Link] for writing.\n";
return;
ordersFile << orderID << "," << customerName << "," << pizzaType << "," << quantity << ","
<< totalPrice << "," << paymentMethod << "," << orderTime << endl;
[Link]();
cout << "Order processed successfully for " << customerName << ". Total: PHP " << fixed << setprecision(2) <<
totalPrice << endl;
} else {
cout << "Order failed due to insufficient inventory.\n";
// Show Inventory
void showInventory() {
cout << "\nCurrent Inventory:\n";
for (const auto& item : inventory) {
cout << [Link] << ": " << [Link] << endl;
// Customer Personalization
void suggestPizzas() {
cout << "\nTop 3 Recommended Pizzas for You:\n";
cout << "1. Margherita\n2. Pepperoni\n3. Veggie Delight\n";
}
// Real-Time Sales Report
void salesReport() {
ifstream ordersFile("[Link]");
if (!ordersFile.is_open()) {
cout << "No sales data available.\n";
return;
map<string, pair<int, double>> salesData;
string line;
while (getline(ordersFile, line)) {
vector<string> tokens;
size_t pos = 0;
// Tokenize the line by commas
while ((pos = [Link](',')) != string::npos) {
tokens.push_back([Link](0, pos));
[Link](0, pos + 1);
tokens.push_back(line);
if ([Link]() != 7) {
cout << "Skipping malformed line: " << line << endl;
continue;
try {
string pizzaType = tokens[2];
int quantity = stoi(tokens[3]);
double totalPrice = stod(tokens[4]);
salesData[pizzaType].first += quantity;
salesData[pizzaType].second += totalPrice;
} catch (const exception& e) {
cout << "Error parsing line: " << line << ". Skipping this line.\n";
continue;
[Link]();
cout << "\nSales Report:\n";
for (const auto& data : salesData) {
cout << "Pizza Type: " << [Link] << ", Total Sold: " << [Link]
<< ", Total Revenue: PHP " << fixed << setprecision(2) << [Link] << endl;
// Delete Sales Report
void deleteSalesReport() {
if (remove("[Link]") == 0) {
cout << "\nSales report successfully deleted.\n";
} else {
cout << "\nError: Could not delete the sales report. File may not exist.\n";
// Main Function
int main() {
int choice, orderID = 1;
while (true) {
cout << "\n--- Rafael's Pizza Management System ---\n";
cout << "1. Process Order\n2. Show Inventory\n3. Customer Personalization\n4. View Sales Report\n5. Delete Sales
Report\n6. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
if (choice == 1) {
string customerName, pizzaType, paymentMethod;
int quantity;
double pricePerPizza;
cout << "Enter customer name: ";
[Link](numeric_limits<streamsize>::max(), '\n');
getline(cin, customerName);
cout << "Enter pizza type: ";
getline(cin, pizzaType);
cout << "Enter quantity: ";
while (!(cin >> quantity) || quantity <= 0) {
cout << "Invalid input. Please enter a positive number for quantity: ";
[Link]();
[Link](numeric_limits<streamsize>::max(), '\n');
cout << "Enter price per pizza: ";
while (!(cin >> pricePerPizza) || pricePerPizza <= 0) {
cout << "Invalid input. Please enter a positive number for price: ";
[Link]();
[Link](numeric_limits<streamsize>::max(), '\n');
cout << "Enter payment method (Cash/Card): ";
[Link](numeric_limits<streamsize>::max(), '\n');
getline(cin, paymentMethod);
if (paymentMethod != "Cash" && paymentMethod != "Card") {
cout << "Invalid payment method. Defaulting to 'Cash'.\n";
paymentMethod = "Cash";
processOrder(orderID++, customerName, pizzaType, quantity, pricePerPizza, paymentMethod);
} else if (choice == 2) {
showInventory();
} else if (choice == 3) {
suggestPizzas();
} else if (choice == 4) {
salesReport();
} else if (choice == 5) {
deleteSalesReport();
} else if (choice == 6) {
cout << "Exiting. Goodbye!\n";
break;
} else {
cout << "Invalid choice. Try again.\n";
return 0;
}
Web System and Technologies
Source Code:
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Form</title>
<style>
body {
margin: 0;
font-family: Arial, sans-serif;
background-color: #c4e1b9;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
.container {
background-color: #accfaf;
border: 2px solid #46a049;
padding: 20px;
width: 350px;
border-radius: 8px;
text-align: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
img {
width: 80px;
margin-bottom: 10px;
.input-field {
display: block;
width: 100%;
margin: 10px 0;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 16px;
button {
background-color: #308be3;
color: white;
border: none;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
border-radius: 4px;
margin-top: 10px;
button:hover {
background-color: #2669b8;
</style>
</head>
<body>
<div class="container">
<img src="[Link]
alt="Logo">
<input type="text" class="input-field" placeholder="Username" value="admin">
<input type="password" class="input-field" placeholder="Password" value="12345">
<button onclick="[Link]='[Link]'">Sign in</button>
</div>
</body>
</html>
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Administrator Panel</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
body {
display: flex;
flex-direction: column;
height: 100vh;
background-color: #f9f9f9;
}
/* Top Header */
.header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #f8f9fa;
padding: 10px 20px;
border-bottom: 1px solid #ddd;
.header .logo {
font-weight: bold;
font-size: 20px;
color: #333;
text-align: left;
.header .user {
font-size: 14px;
color: #666;
/* Main Content */
.main-container {
display: flex;
height: 100%;
/* Sidebar */
.sidebar {
width: 220px;
background-color: #f8f9fa;
border-right: 1px solid #ddd;
padding: 10px 0;
.sidebar ul {
list-style: none;
.sidebar li {
padding: 10px 20px;
font-size: 14px;
color: #333;
cursor: pointer;
.sidebar li:hover {
background-color: #e2e6ea;
.sidebar li .badge {
background-color: #007bff;
color: #fff;
font-size: 12px;
padding: 2px 6px;
border-radius: 3px;
margin-left: 10px;
/* Content Area */
.content {
flex: 1;
padding: 20px;
}
.content .notification {
background-color: #d4edda;
color: #155724;
padding: 10px;
border: 1px solid #c3e6cb;
border-radius: 4px;
margin-bottom: 20px;
.content h1 {
font-size: 24px;
font-weight: bold;
color: #333;
</style>
</head>
<body>
<!-- Header -->
<div class="header">
<img src="[Link] alt="">
<div class="logo">Green Valley College Foundation, Inc.</div>
<div class="user">Hi, Admin</div>
</div>
<!-- Main Content -->
<div class="main-container">
<!-- Sidebar -->
<div class="sidebar">
<ul>
<li>🏠 Home</li>
<li>🧑🎓 New Enrollees</li>
<li>📘 Subjects</li>
<li>🏢 Department</li>
<li>📚 Courses</li>
<li>📅 Schedule</li>
<li>👥 Students</li>
<li>👨🏫 Instructor</li>
<li>🗓 Set Semester</li>
<li>🏫 Classroom Utilization</li>
<li>📊 Report</li>
<li>👤 Users</li>
<li>🔄 Back-up and Restore</li>
</ul>
</div>
<!-- Content -->
<div class="content">
<div class="notification">
You logon as Administrator.
</div>
<h1>Welcome to the Administrator Panel</h1>
</div>
</div>
</body>
</html>