diff --git a/EmailCarbonFootPrint.cpp b/EmailCarbonFootPrint.cpp new file mode 100644 index 0000000..1e0f36f --- /dev/null +++ b/EmailCarbonFootPrint.cpp @@ -0,0 +1,27 @@ +#include +#include + +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; + } +}; diff --git a/Main.cpp b/Main.cpp new file mode 100644 index 0000000..f9cda8f --- /dev/null +++ b/Main.cpp @@ -0,0 +1,40 @@ +#include +#include +#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; +} \ No newline at end of file