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

Image
  🌿  Smart Garden Manager in C++ with Robotics, UI, Drones, and Sound "A Rainwater Conservation System for Tomorrow’s Farms" 🧭  1. Introduction: Farming in the Age of Climate Change In a world where clean water is more precious than gold, efficient  rainwater harvesting and plant care systems  are no longer optional — they’re essential. Smart farming doesn’t mean just automating irrigation. It means combining  robotic drones, environmental sensors, and intelligent scheduling  to build a garden that practically takes care of itself. In this guide, we build a  fully functional Garden Manager System  using  C++  that: Captures and conserves rainwater Uses  robotic drones and sensors  to monitor crop health Integrates a  real-time UI  with progress bars and alerts Includes  timers  for scheduling plant growth and drone tasks Plays  interactive sounds  based on crop state and events Whether you'r...

C++ Mini Projects: Student Grade Calculator

C++ Mini Projects: Student Grade Calculator

Hey everyone, welcome back to the series. Remember we built a simple calculator back in the series, now this is going to be a bit advance version of that calculator. So make sure you haven't missed that blog before starting to understand and work on this one.

Here is what its going to do: Input marks for different subjects, calculate the average, and display the grade. This project enables the user in 
. Inputting marks for all subjects
. calculation of average marks
. assignment of grades based on marks
Here is a short example:
Grade A >=90
Grade B>=80
Grade C>=70 
Grade D>=60
Grade F<60

Skills you will learn throughout: Conditional statements and arithmetic operations.

Here is the go to build the desired project:

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int numSubjects;
    vector<double> marks;
    double total = 0, average = 0;
    char grade;

    // Input the number of subjects
    cout << "Student Grade Calculator\n";
    cout << "------------------------\n";
    cout << "Enter the number of subjects: ";
    cin >> numSubjects;

    // Input marks for each subject
    for (int i = 0; i < numSubjects; ++i) {
        double mark;
        cout << "Enter marks for subject " << i + 1 << ": ";
        cin >> mark;
        marks.push_back(mark); // Add mark to the vector
        total += mark; // Add mark to the total
    }

    // Calculate average
    average = total / numSubjects;

    // Determine grade
    if (average >= 90) {
        grade = 'A';
    } else if (average >= 80) {
        grade = 'B';
    } else if (average >= 70) {
        grade = 'C';
    } else if (average >= 60) {
        grade = 'D';
    } else {
        grade = 'F';
    }

    // Display results
    cout << "\nResults:\n";
    cout << "Total Marks: " << total << endl;
    cout << "Average Marks: " << average << endl;
    cout << "Grade: " << grade << endl;

    return 0;
}

How the code works?

marks.push_back(mark)

Storing marks in vector

Total ...
Keeps the sum of all marks that are entered

Calculation of average...
average = total / numSubjects;

Division of total marks by number of subjects to obtain average 

Assignment of grades....

if (average >= 90) {
    grade = 'A';
} else if (average >= 80) {
    grade = 'B';
} else if (average >= 70) {
    grade = 'C';
} else if (average >= 60) {
    grade = 'D';
} else {
    grade = 'F';
}

Using else if statements for comparing average marks
Assignment of grades based on average marks


Displaying result...

cout << "Total Marks: " << total << endl;
cout << "Average Marks: " << average << endl;
cout << "Grade: " << grade << endl;

Displays average marks and grades accordingly 


Input

Enter the number of subjects: 5
Enter marks for subject 1: 85
Enter marks for subject 2: 78
Enter marks for subject 3: 92
Enter marks for subject 4: 88
Enter marks for subject 5: 76


Output 
Results:
Total Marks: 419
Average Marks: 83.8
Grade: B

So you can see our program is working fine now and deals with all kind of calculations of average and effectively gives the grade. 


Thanks for being with me and I will see you next time.

Comments

Popular posts from this blog

C++ Projects: Basic Traffic Management System

C++ Projects: Book Shop Management System

C++ Projects: Password Manager