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

I\'m trying to write a program in Microsoft Visual 2010 that sends information f

ID: 3657684 • Letter: I

Question

I'm trying to write a program in Microsoft Visual 2010 that sends information from the program to a file and the output should be:

I've written the code and have inserted comments to explain what I'm having trouble with. I'd really appreciate the help, this is my first C++ course and I understand some portions of the coding logic but I'm not that great with others! Thanks again!


#include <iostream>

#include <iomanip>

#include <fstream>

#include <string>

#include <cstdlib>

using namespace std;

int calculateArray(int []); //calculates the sum of an array of integers

const int MAXELS = 11;

int _tmain(int argc, _TCHAR* argv[])

{

string filename = ?bowlers.txt?;

ofstream outFile;

outFile.open(bowlers.txt());

if(outFile.fail())

{

cout << " The file was not successfully opened "

<< " Please check that the file currently exists."

<< endl;

exit (1);

}

else

outFile << fixed << showpoint << setprecision(2);

//HERE: You will need to declare the outFile object

string jeff = "Jeff";

int jeff_score[MAXELS]= {10, 6, 7, 9, 5, 8, 7, 9, 6, 10};

string charles = "Charles";

int charles_score[MAXELS] = {9, 10, 4, 8, 7, 9, 3, 8, 10, 9};

string sue = "Sue";

int sue_score[MAXELS] = {9, 7, 8, 9, 4, 7, 9, 9, 8, 9};

string ed = "Ed";

int ed_score[MAXELS] = {10, 9, 9, 9, 10, 9, 9, 9, 10, 10};

string micki = "Micki";

int micki_score[MAXELS] = {4, 6, 5, 8, 9, 6, 3, 8, 8, 9};

string george = "George";

int george_score[MAXELS] = {2, 3, 7, 1, 10, 9, 5, 8, 9, 5};

string zack = "Zack";

int zack_score[MAXELS] = {7, 8, 9, 9, 4, 5, 6, 9, 9, 8};

//HERE: You need to call the calculateArray function using the bowlers' scores as an argument (respectively)

int calculateArray(int [jeff_score], int [charles_score], int[sue_score], int[ed_score], int[micki_score], int[george_score], int[zack_score])

//HERE: You need to write the bowlers' final score to bowlers.txt

outFile << ?Jeff? << 77 << endl

<< ?Charles? << 77 << endl

<< ?Sue? << 79 << endl

<< ?Ed? << 94 << endl

<< ?Micki? << 66 << endl

<< ?George? << 59 << endl

<< ?Zack? << 74 << endl;


outFile.close();

cout << "The file has been successfully written";


return 0;

}

int calculateArray(int a[]){

//HERE: This function should take an integer array, calculate the sum of its items, and return the sum as an integer

int i, jeff, charles, sue, ed, micki, george, zack;

charles = charles_score;

sue = sue_score;

ed = ed_score;

micki = micki_score;

george = george_score;

zack = zack_score;

sum1 = 0;

for (i = 0; i < jeff; i++)

sum1 +=jeff[i];

cout << sum1;

sum2 = 0;

for (i = 0; i < charles; i++)

sum1 +=charles[i];

cout << sum2;

}

Explanation / Answer

check it http://www.daniweb.com/software-development/cpp/threads/116338/i-have-to-write-a-program-to-read-10-integers-into-an-array