#include #include #include using namespace std; int main() { int monthlyUsage[12]; double consumption[12]; double discount[12]; double tax[12]; double bill[12]; string fullMonthName[12] = { "January","February","March","April","May","June","July","August","September","October","November","December" }; string month[12] = { "Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"}; for (int i = 0; i < 12; i++) { cout << "please input monthly usage in kWh for " << fullMonthName[i] << ": " <> monthlyUsage[i]; // Get user input and put it inside array monthlyUsage // TO DO CALCULATION FOR THE CONSUMPTION if (monthlyUsage[i] > 0 && monthlyUsage[i] < 101) { consumption[i] = (17.5/100) * monthlyUsage[i]; } else if (monthlyUsage[i] > 100 && monthlyUsage[i] < 201) { consumption[i] = 17.5 + ((monthlyUsage[i] - 100) * (18.5 / 100)); } else if (monthlyUsage[i] > 200 && monthlyUsage[i] < 301) { consumption[i] = 17.5 + 18.5 + ((monthlyUsage[i] - 200) * (33.0 / 100)); } else if (monthlyUsage[i] > 300 && monthlyUsage[i] < 501) { consumption[i] = 17.5 + 18.5 + 33.0 + ((monthlyUsage[i] - 300) * (44.5 / 100)); } else if (monthlyUsage[i] > 500 && monthlyUsage[i] < 1001) { consumption[i] = 17.5 + 18.5 + 33.0 + 44 + ((monthlyUsage[i] - 400) * (45.0 / 100)); } else { consumption[i] = 7.0 + 18.5 + 33.0 + 44.5 + 45.0 + ((monthlyUsage[i] - 500) * (47.0 / 100)); } // GET THE DISCOUNT IF THE CONSUMPTION IS EQUALS OR LESS THAN RM600 if (consumption[i] <= 600) { discount[i] = consumption[i] * 0.1; // Calculate 10 % discount and put the result inside discount array bill[i] = consumption[i] - discount[i]; // Substract the discount with the consumption and put the result inside bill array } else { discount[i] = 0.0; // Else discount is 0 } // GET THE TAX IF THE CONSUMPTION IS MORE THAN RM600 if (consumption[i] > 600) { tax[i] = consumption[i] * 0.06;// Calculate tax 6% and put the result inside tax array bill[i] = consumption[i] + tax[i];// Add the tax with the consumption and put the result inside bill array } else { tax[i] = 0.0; // Else tax is 0 } } cout << "\n\nMonth\tUsage(kWh)\tConsumption(RM)\t10% Discount\t\t6% Tax(RM)\t\tBill(RM)\n"; // TO DISPLAY THE OUTPUT for (int i = 0; i < 12; i++) { cout << month[i] << "\t" << setprecision(2) << fixed << monthlyUsage[i] <<"\t\t"<< setprecision(2) << fixed << consumption[i] << "\t\t" << setprecision(2) << fixed << discount[i] << "\t\t\t" << setprecision(2) << fixed << tax[i] << "\t\t\t" << setprecision(2) << fixed << bill[i]; cout << endl; } } Explain this program in words in at least 1 page
#include <iostream> #include <string> #include<iomanip> using namespace std; int main() { int monthlyUsage[12]; double consumption[12]; double discount[12]; double tax[12]; double bill[12]; string fullMonthName[12] = { "January","February","March","April","May","June","July","August","September","October","November","December" }; string month[12] = { "Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"}; for (int i = 0; i < 12; i++) { cout << "please input monthly usage in kWh for " << fullMonthName[i] << ": " <<endl; cin >> monthlyUsage[i]; // Get user input and put it inside array monthlyUsage // TO DO CALCULATION FOR THE CONSUMPTION if (monthlyUsage[i] > 0 && monthlyUsage[i] < 101) { consumption[i] = (17.5/100) * monthlyUsage[i]; } else if (monthlyUsage[i] > 100 && monthlyUsage[i] < 201) { consumption[i] = 17.5 + ((monthlyUsage[i] - 100) * (18.5 / 100)); } else if (monthlyUsage[i] > 200 && monthlyUsage[i] < 301) { consumption[i] = 17.5 + 18.5 + ((monthlyUsage[i] - 200) * (33.0 / 100)); } else if (monthlyUsage[i] > 300 && monthlyUsage[i] < 501) { consumption[i] = 17.5 + 18.5 + 33.0 + ((monthlyUsage[i] - 300) * (44.5 / 100)); } else if (monthlyUsage[i] > 500 && monthlyUsage[i] < 1001) { consumption[i] = 17.5 + 18.5 + 33.0 + 44 + ((monthlyUsage[i] - 400) * (45.0 / 100)); } else { consumption[i] = 7.0 + 18.5 + 33.0 + 44.5 + 45.0 + ((monthlyUsage[i] - 500) * (47.0 / 100)); } // GET THE DISCOUNT IF THE CONSUMPTION IS EQUALS OR LESS THAN RM600 if (consumption[i] <= 600) { discount[i] = consumption[i] * 0.1; // Calculate 10 % discount and put the result inside discount array bill[i] = consumption[i] - discount[i]; // Substract the discount with the consumption and put the result inside bill array } else { discount[i] = 0.0; // Else discount is 0 } // GET THE TAX IF THE CONSUMPTION IS MORE THAN RM600 if (consumption[i] > 600) { tax[i] = consumption[i] * 0.06;// Calculate tax 6% and put the result inside tax array bill[i] = consumption[i] + tax[i];// Add the tax with the consumption and put the result inside bill array } else { tax[i] = 0.0; // Else tax is 0 } } cout << "\n\nMonth\tUsage(kWh)\tConsumption(RM)\t10% Discount\t\t6% Tax(RM)\t\tBill(RM)\n"; // TO DISPLAY THE OUTPUT for (int i = 0; i < 12; i++) { cout << month[i] << "\t" << setprecision(2) << fixed << monthlyUsage[i] <<"\t\t"<< setprecision(2) << fixed << consumption[i] << "\t\t" << setprecision(2) << fixed << discount[i] << "\t\t\t" << setprecision(2) << fixed << tax[i] << "\t\t\t" << setprecision(2) << fixed << bill[i]; cout << endl; } }
Explain this program in words in at least 1 page
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)