#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

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

#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

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY