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

Post C++ code that will do the following: Create an Excel file called NeplanDiag

ID: 3880291 • Letter: P

Question

Post C++ code that will do the following:

Create an Excel file called NeplanDiagram

Creat 2 variables, Power and Reactive… initialize both at 0

Set Power to 0.1 and increment Reactive from 0 to 2 in steps of 0.1

Add Power and Reactive in each step

Export the power, reactive, and the summation for each iteration, into 3 separate columns in excel

Save

Set Power to 0.2 and increment Reactive from 0 to 2 in steps of 0.1

Add Power and Reactive in each step

Export the power, reactive, and the summation for each iteration, into 3 separate columns in excel

Save

Repeat this up until Power is set to 2.0

Each time saving the data with an empty column separating the information

At the end the excel file should look like the following.

Please post the code and possible a link to where I can download the actual files.

Sum Power: 0.2 Reactive: 0-2 0 0.1 Power: 0.1 Reactive: 0-2 Sum 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 4 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10 12 13 1.2 15 16 17 1.6 1.7 1.8 1.9 1.4 1.5 1.6 1.7 1.8 1.9 1.6 1.7 1.8 1.9 1.6 1.7 1.8 20 21 2.1 2.2 0.1 2.1 23 24

Explanation / Answer

#include <iostream>

#include <sstream>

#include <fstream>

using namespace std;

// This method will calculate each line in the excel sheet

string calculate(double power, double reactive) {

stringstream data;

while(power <= 2) {

power += 0.10;

data << power << "," << reactive << "," << (power+reactive) << ",,";

}

return data.str();

}

int main() {

ofstream my_excel;

// This statement will create the file

my_excel.open("F:\test.csv");

double power = 0.0;

string;

stringstream data;

// This while loop will print the header information

while(power <= 2) {

power += 0.10;

data << "Power " << power << one_menu;

}

data << endl;

double reactive = 0.0;

// This while loop will increment the value of reactive variable

while(reactive <= 2) {

data << calculate(0.0,reactive) << endl;

reactive += 0.1;

}

data << calculate(0.0,2.0) << endl;

// This statement will write the data on to the file

my_excel << data.str();

// This statement will close the file.

my_excel.close();

return 0;

}