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: Calendar Application

C++ Mini Projects: Calendar Application

Hey guys! Today, we are going to build something simple yet useful using our skills in C++. As the name suggests, it's going to be a calendar application. We all know what a calendar does, so let's jump right in and start building!


Skills Used

  • Input of Month and Year: Users will input the desired month and year.
  • Displaying the Calendar: The application will generate a properly formatted calendar for the given input.
  • Highlighting Weekends: Weekends will be enclosed in parentheses.
  • Marking Important Dates: Users can specify important dates to be highlighted.

The Code to Build the Project

#include <iostream>
#include <iomanip> // for setw
#include <vector>
using namespace std;

bool isLeapYear(int year) {
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}

int getDaysInMonth(int month, int year) {
    if (month == 2) {
        return isLeapYear(year) ? 29 : 28;
    }
    if (month == 4 || month == 6 || month == 9 || month == 11) {
        return 30;
    }
    return 31;
}

int getFirstDayOfMonth(int month, int year) {
    int day = 1, y = year, m = month;
    if (m < 3) {
        m += 12;
        y -= 1;
    }
    int k = y % 100, j = y / 100;
    int firstDay = (day + (13 * (m + 1)) / 5 + k + (k / 4) + (j / 4) - (2 * j)) % 7;
    return (firstDay + 5) % 7;
}

void displayCalendar(int month, int year, const vector<int>& importantDates) {
    vector<string> months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
    
    cout << "\n " << months[month - 1] << " " << year << endl;
    cout << " Sun Mon Tue Wed Thu Fri Sat" << endl;

    int daysInMonth = getDaysInMonth(month, year);
    int firstDay = getFirstDayOfMonth(month, year);
    
    for (int i = 0; i < firstDay; ++i) {
        cout << "    ";
    }
    
    for (int day = 1; day <= daysInMonth; ++day) {
        bool isWeekend = (firstDay % 7 == 0 || firstDay % 7 == 6);
        bool isImportant = find(importantDates.begin(), importantDates.end(), day) != importantDates.end();
        
        if (isImportant) {
            cout << setw(5) << "*" + to_string(day) + "*";
        } else if (isWeekend) {
            cout << setw(5) << "(" + to_string(day) + ")";
        } else {
            cout << setw(5) << day;
        }
        
        ++firstDay;
        if (firstDay % 7 == 0) {
            cout << endl;
        }
    }
    cout << endl;
}

int main() {
    int year, month;
    vector<int> importantDates;
    
    cout << "Welcome to the Calendar Application!" << endl;
    cout << "Enter the year: ";
    cin >> year;
    cout << "Enter the month (1-12): ";
    cin >> month;
    
    int numImportant;
    cout << "Enter the number of important dates to mark: ";
    cin >> numImportant;
    cout << "Enter the important dates (day of the month): ";
    for (int i = 0; i < numImportant; ++i) {
        int date;
        cin >> date;
        importantDates.push_back(date);
    }
    
    displayCalendar(month, year, importantDates);
    
    return 0;
}

Explanation

  • Leap Year Calculation: Determines if a given year is a leap year.
  • Days in a Month: Adjusts for varying month lengths and leap years.
  • First Day of the Month: Uses Zeller's Congruence algorithm to determine the first day of a given month.
  • Calendar Display: Formats the output to show weekends in parentheses and important dates marked with asterisks.
  • User Input Handling: Ensures users provide valid months and dates.

Real-World Applications

Personal Schedules and Reminders

People often use calendar apps to mark events, deadlines, and meetings. This project lays the foundation for building a fully functional scheduling tool.

Automatic Payments and Billing Systems

Many subscription-based services use calendar logic to automate billing cycles. This program demonstrates how to track dates efficiently.

Employee Attendance Tracking

Businesses use calendar-based applications to manage employee attendance, shifts, and leave schedules.

Case Study: Google Calendar

Google Calendar helps users manage schedules, special events, and reminders. Our project follows a similar concept by allowing users to mark different dates.

Financial Market Planning

Businesses rely on calendar applications to track tax deadlines, financial reports, and investment schedules.

University Class Scheduling

Universities use scheduling software for managing classes, exams, and holidays. This project can be extended to create a comprehensive timetable planner.


Problem-Solving Approaches

Handling User Input

  • Ensures valid month selection (1-12).
  • Prevents invalid date entries for selected months.
  • Uses loops to re-prompt users in case of incorrect input.

Formatting the Output Properly

  • Uses setw() for aligning calendar columns.
  • Highlights weekends and important dates clearly.

Adding Modern Features

  • Implementing a graphical interface for better user experience.
  • Extending the project to integrate with database storage for event persistence.

This project is a great starting point for building advanced calendar applications. I hope you liked it! See you again with another cool project soon!

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"