From db25775d6717f1fd6b9245f133972bf072c8d476 Mon Sep 17 00:00:00 2001 From: PradeepITT <148972812+PradeepITT@users.noreply.github.com> Date: Mon, 30 Oct 2023 10:42:34 +0530 Subject: [PATCH 1/3] Added code of Carbon Footprint --- EmailCarbonFootPrint.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 EmailCarbonFootPrint.cpp diff --git a/EmailCarbonFootPrint.cpp b/EmailCarbonFootPrint.cpp new file mode 100644 index 0000000..86818a0 --- /dev/null +++ b/EmailCarbonFootPrint.cpp @@ -0,0 +1,51 @@ +#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; + } +}; + +// Function to input email data +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; +} + +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; + InputEmailData(spam_Emails, standard_Emails, attachment_Emails); + EmailCarbonFootprint emailFootprint(spam_Emails, standard_Emails, attachment_Emails); + emailFootprint.DisplayDayTotal(); + return 0; +} From bc6d92f602530bb0b6453b0e5ae0953a60ae25a3 Mon Sep 17 00:00:00 2001 From: PradeepITT <148972812+PradeepITT@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:46:51 +0530 Subject: [PATCH 2/3] Update EmailCarbonFootPrint.cpp --- EmailCarbonFootPrint.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/EmailCarbonFootPrint.cpp b/EmailCarbonFootPrint.cpp index 86818a0..1e0f36f 100644 --- a/EmailCarbonFootPrint.cpp +++ b/EmailCarbonFootPrint.cpp @@ -25,27 +25,3 @@ class EmailCarbonFootprint { cout << "Total: " << Total_CarbonFootprint << " g CO2e" << endl; } }; - -// Function to input email data -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; -} - -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; - InputEmailData(spam_Emails, standard_Emails, attachment_Emails); - EmailCarbonFootprint emailFootprint(spam_Emails, standard_Emails, attachment_Emails); - emailFootprint.DisplayDayTotal(); - return 0; -} From a007c90bff665887e3c7e35ef130b5585406c317 Mon Sep 17 00:00:00 2001 From: PradeepITT <148972812+PradeepITT@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:54:33 +0530 Subject: [PATCH 3/3] Updated Int Main --- Main.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Main.cpp 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