Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions EmailCarbonFootPrint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <iostream>
#include <string>

using namespace std;

class EmailCarbonFootprint {
public:
double Inbox_CarbonFootprint;
double Sent_CarbonFootprint;
double Spam_CarbonFootprint;
double Total_CarbonFootprint;

EmailCarbonFootprint(int spam_Emails, int standard_Emails, int with_attachment_Emails) {
Inbox_CarbonFootprint = spam_Emails * 0.3 + standard_Emails * 4;
Sent_CarbonFootprint = standard_Emails * 4;
Spam_CarbonFootprint = spam_Emails * 0.3;
Total_CarbonFootprint = Inbox_CarbonFootprint + Sent_CarbonFootprint + with_attachment_Emails * 50;
}

void DisplayDayTotal() {
cout << "Carbon Footprint of Emails in a day" << endl;
cout << "Inbox: " << Inbox_CarbonFootprint << " g CO2e" << endl;
cout << "Sent: " << Sent_CarbonFootprint << " g CO2e" << endl;
cout << "Spam: " << Spam_CarbonFootprint << " g CO2e" << endl;
cout << "Total: " << Total_CarbonFootprint << " g CO2e" << endl;
}
};
40 changes: 40 additions & 0 deletions Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <iostream>
#include <string>
#include "EmailCarbonFootprint.cpp"

void InputEmailData(int& spam_Emails, int& standard_Emails, int& attachment_Emails) {
cout << "Enter the number of spam emails received: ";
cin >> spam_Emails;

cout << "Enter the number of standard emails received: ";
cin >> standard_Emails;

cout << "Enter the number of emails with attachments received: ";
cin >> attachment_Emails;
}

bool ValidateEmailData(int spam_Emails, int standard_Emails, int attachment_Emails) {
if (spam_Emails < 0 || standard_Emails < 0 || attachment_Emails < 0) {
return false;
}

return true;
}

int main() {
cout << "Email Carbon Footprint Calculator" << endl;
string email_Id;
cout << "Enter the Email Id : ";
cin>>email_Id;
int spam_Emails, standard_Emails, attachment_Emails;
PromptEmailData(spam_Emails, standard_Emails, attachment_Emails);

if (!ValidateEmailData(spam_Emails, standard_Emails, attachment_Emails)) {
cout << "Invalid input. Please enter positive integers for the number of emails." << endl;
return 1;
}

EmailCarbonFootprint emailFootprint(spam_Emails, standard_Emails, attachment_Emails);
emailFootprint.DisplayDayTotal();
return 0;
}