The Muggy Weather Robotics Duo

Image
 The Muggy Weather Robotics Duo A C++ System That Thinks, Feels (Sensors!), and Acts Humidity is like the quiet character in the weather story that actually runs the show. On muggy days, everything feels heavier—breathing, drying laundry, running machines, even keeping a data center cool. For people, it’s about comfort and health; for machines, it’s about performance and reliability; for plants and buildings, it’s about moisture balance and mold risk. In robotics and automation, muggy weather isn’t just a nuisance—it’s a signal . It tells your systems when to ventilate, when to dehumidify, when to throttle physically demanding tasks, and when to take preventative maintenance actions. Today, we’ll build a two-program C++ system that “understands” muggy weather: Program A — sensor_hub.cpp A sensor-side program that generates (or ingests) a live stream of environmental data (temperature, relative humidity, pressure, CO₂, VOCs). Think of it as your robotic nose and skin , con...

C++ Mini Projects: Recipe Book

C++ Mini Projects: Recipe Book

Hey guys, today we are going to build a recipe book project. This is a console-based, simple recipe book where users can not only search and view but also add, update, or delete recipes in the system.

Each recipe will contain information such as the name, ingredients, and step-by-step method. All data will be stored in files for persistence. So what are we waiting for? Let's jump in and get started!

Skills Used

File Handling

Used for saving the recipes and retrieving them for later use.

Vectors

Used for storing and manipulating different recipes efficiently.

Functions

Used for managing code by dividing it into reusable parts.

Strings

Used for names of recipes, ingredients, and step-by-step instructions.

The Code to Build the Project

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;

// Structure to store recipe details
struct Recipe {
    string name;
    vector<string> ingredients;
    string steps;
};

// Function to display a menu
void displayMenu() {
    cout << "\n--- Recipe Book Menu ---\n";
    cout << "1. Add Recipe\n";
    cout << "2. View All Recipes\n";
    cout << "3. Search Recipe by Name\n";
    cout << "4. Search Recipe by Ingredient\n";
    cout << "5. Update Recipe\n";
    cout << "6. Delete Recipe\n";
    cout << "7. Exit\n";
    cout << "Choose an option: ";
}

// Function to add a new recipe
void addRecipe(vector<Recipe>& recipes, const string& filename) {
    Recipe recipe;
    cout << "Enter recipe name: ";
    cin.ignore();
    getline(cin, recipe.name);
    
    cout << "Enter ingredients (comma-separated): ";
    string ingredientsLine;
    getline(cin, ingredientsLine);
    stringstream ss(ingredientsLine);
    string ingredient;
    while (getline(ss, ingredient, ',')) {
        recipe.ingredients.push_back(ingredient);
    }
    
    cout << "Enter steps: ";
    getline(cin, recipe.steps);

    recipes.push_back(recipe);

    // Save to file
    ofstream file(filename, ios::app);
    if (file) {
        file << recipe.name << "\n";
        for (const auto& ing : recipe.ingredients) {
            file << ing << ",";
        }
        file << "\n" << recipe.steps << "\n";
        file << "-----\n";
        file.close();
    } else {
        cout << "Error saving to file.\n";
    }
}

int main() {
    vector<Recipe> recipes;
    const string filename = "recipes.txt";

    int choice;
    do {
        displayMenu();
        cin >> choice;

        switch (choice) {
        case 1:
            addRecipe(recipes, filename);
            break;
        case 7:
            cout << "Exiting program.\n";
            break;
        default:
            cout << "Invalid choice. Try again.\n";
        }
    } while (choice != 7);

    return 0;
}

Explanation

Storing the Data

All recipes are stored in a text file (recipes.txt). Each recipe includes a name, ingredients, and a step-by-step process.

  • Users can input recipe details and save them using the addRecipe function.
  • The viewRecipes function allows users to view all stored recipes.
  • Users can search for recipes by name or ingredient using applied filters.
  • The deleteRecipe function allows users to delete a recipe and update storage.
  • The loadRecipes function loads stored recipes from files, enabling persistent data handling.

Real-World Examples and Problem-Solving Approaches

Restaurant Management

Restaurants often use digital recipe books to manage menu items efficiently and ensure consistency.

Tracking Diets

Users can save recipes based on dietary preferences (e.g., vegetarian, keto) and filter them by ingredients.

Community Sharing

This project can be expanded into a web-based application where users share their special recipes with a larger community.

Search Optimization

Implementing a robust search algorithm like fuzzy searching enables users to find recipes even with minor spelling errors.

Data Persistence

Using a database instead of text files would allow for more scalable and efficient storage, especially for large applications.


I hope you enjoyed this project! Stay tuned for more cool C++ mini-projects.

Comments

Popular posts from this blog

C++ Projects: Basic Traffic Management System

C++ Projects: Book Shop Management System

🌿 Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms"