Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project Electricity Generation (2) |Compatibility Model-Word Layout References M

ID: 3857035 • Letter: P

Question

Project Electricity Generation (2) |Compatibility Model-Word Layout References Mailings Review Vew Tell me what you want to de Heading 1 Heading2 Tele Paragraph Electricity is generated nationwide from a number of sources, including coal, nuclear, hydroelectric, wind, and more. The Department of Energy publishes various reports each year related to energy. Some of the reports are located at http://www.eia.doe gov/emeu/aer/elect.html. One of the reports is: Table 8.2b Electricity Net Generation: Electric Power Sector, 1949-2013. A subset of this table for 1980-2015 with formatting and headings removed) is available on Blackboard in the data file is named Energy Data.dat. It is shown below. The file Energy.dat is arranged as follows: Column 1 contains the year. Columns 2-14 contain the following information: umn Energy (in Million Kilowatt-hours) generated by Energy Category Coal Petroleunm Natural Gas Other Gases Nuclear Electric Power Hydro-Electric Pumped Power Conventional Hydro-Electric Biomass- Wood Biomass-Waste Geothermal Solar Wind Fossil Fuel Fossil Fuel Fossil Fuel Fossil Fuel Nuclear Hydro-Electric Renewable Renewable Renewable Renewable Renewable Renewable 10 12 13 DOLL

Explanation / Answer

#include<iostream>
#include<fstream>


#define FOSSILF 15
#define NEUCLEARF 16
#define HYDROF 17
#define RENEWABLEF 18
#define TOTAL 14

#define WIND 12
#define SOLAR 11
#define GEOTHERMAL 10
#define BIOMWAST 9
#define BIOMWOOD 8
#define HYDRO 7
#define HYDROP 6
#define NEUCLEAR 5
#define OGAS 4
#define NGAS 3
#define PETROLIUM 2
#define COAL 1
using namespace std;

int energy[65][19];
int total_energy[19];
int count = 0;
int readData(ifstream &fin) {
   int total_year;
   while (!fin.eof()) {
       total_year = 0;
       for (int i = 0; i<13; i++) {
           fin >> energy[count][i];
           total_year += energy[count][i];
           total_energy[i] += energy[count][i];
           if (i >= 1 && i <= 4)
               energy[count][FOSSILF] += energy[count][i];
           if (i == 5)
               energy[count][NEUCLEARF] += energy[count][i];
           if (i == 6)
               energy[count][HYDROF] += energy[count][i];  
           if (i >= 7)
               energy[count][RENEWABLEF] += energy[count][i];  
        }
       energy[count][TOTAL] = total_year;
       total_energy[TOTAL] += energy[count][TOTAL]; // is total
       total_energy[FOSSILF] += energy[count][FOSSILF]; // is fossil
       total_energy[NEUCLEARF] += energy[count][NEUCLEARF]; // is neuclear
       total_energy[HYDROF] += energy[count][HYDROF]; // is hydro
       total_energy[RENEWABLEF] += energy[count][RENEWABLEF]; // is renwable
   }
}


int getMaxYear(int k) {
   int max = 0;
   for (int i = 1; i < count; i++)
       if (energy[i][k] > energy[max][k])
           max = i;
   return energy[max][0];
}

int print_year_report(int year) {
   year -= 1949;
   cout << "COAL " << energy[year][COAL] << " " <<(double)energy[year][COAL]/energy[year][TOTAL] << endl;
   cout << "PETROLIUM " << energy[year][PETROLIUM] << " " <<(double)energy[year][PETROLIUM]/energy[year][TOTAL] << endl;
   cout << "NATURAL GAS " << energy[year][NGAS] << " " <<(double)energy[year][NGAS]/energy[year][TOTAL] << endl;
   cout << "OTHER GASES " << energy[year][OGAS] << " " <<(double)energy[year][OGAS]/energy[year][TOTAL] << endl;
   cout << "NEUCLEAR " << energy[year][NEUCLEAR] << " " <<(double)energy[year][NEUCLEAR]/energy[year][TOTAL] << endl;
   cout << "HYDRO-ELEC Pumped " << energy[year][HYDROP] << " " <<(double)energy[year][HYDROP]/energy[year][TOTAL] << endl;
   cout << "HYDRO ELECTRIC " << energy[year][HYDRO] << " " <<(double)energy[year][HYDRO]/energy[year][TOTAL] << endl;
   cout << "BIOMASS wood " << energy[year][BIOMWOOD] << " " <<(double)energy[year][BIOMWOOD]/energy[year][TOTAL] << endl;
   cout << "BIOMASS waste " << energy[year][BIOMWAST] << " " <<(double)energy[year][BIOMWAST]/energy[year][TOTAL] << endl;
   cout << "GEOTHERMAL " << energy[year][GEOTHERMAL] << " " <<(double)energy[year][GEOTHERMAL]/energy[year][TOTAL] << endl;
   cout << "SOLAR " << energy[year][SOLAR] << " " <<(double)energy[year][SOLAR]/energy[year][TOTAL] << endl;
   cout << "WIND " << energy[year][WIND] << " " <<(double)energy[year][WIND]/energy[year][TOTAL] << endl;
   cout << "TOTAL " << energy[year][TOTAL] << " " <<(double)energy[year][TOTAL]/energy[year][TOTAL] << endl;
}

int main() {
   ifstream file;
   file.open("");
   readData(file);
   file.close();
   cout << "1. Option A "
       << "2. Option B "
            << "3. Option C "
   <<"Enter choice: ";
   int choice, year;
   cin >> choice;
   switch(choice) {
       case 1:
           cout << "Enter year for report: ";
           cin >> year;
           print_year_report(year);
           break;
       case 2:
           for (int i = 1; i < 17; i++)
               cout << getMaxYear(i) << endl; /* Print other data*/
           break;
       case 3:
           char str[100];
           cout << "Enter file name: " ;
           cin >> str;
           int col;  
           cout << "Enter column number: ";
           cin >> col;

           ofstream fout;
           fout.open(str);
           for (int i = 0; i < count; i++)
               fout << energy[i][col] << endl;
           fout.close();
   }
}

reason w

The question is too long to be asnweed in a single window. I have provided the framework for you, which you can change a little and ge valid outputs*. I hope you understand the reason why this code maiy fail. Moreover the data quoted in the question is not available, so *i cannto test the code. If you have the data.dat file, do post the link and will update you about the stability of the code.