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

#include <fstream> #include <iostream> #include <string> #include <string> using

ID: 3660288 • Letter: #

Question

#include <fstream>
#include <iostream>
#include <string>
#include <string>

using namespace std;

int main()
{

ifstream inFile;
ofstream outFile;
string element;
string symbol;
string usersymbol;
string correct = 0;
string wrong = 0;


inFile.open("elements.dat"); //open file

while (!inFile.eof())
{


inFile >> element; // get element

inFile.ignore ( );

inFile >> symbol; // get symbol

cout<< "What is the symbol for " << element << "? " << endl; //output element

cin >> usersymbol ;

if (usersymbol == symbol)

{
cout<< "Correct " << endl;

}

else
cout<< "Wrong " << endl;

}



this is what i have so far. i need to increment the variable correct everytime that a user answers correctly and increment the variable wrong everytime the user doesnt get teh answer right. then i need to set a function that will return an average when given the number correct as and input paramater to the function.

Explanation / Answer

It looks like you are not far off, but you need to change these two to ints: string correct = 0; string wrong = 0; should be int correct=0; int wrong =0; //------------------------------------------------------------------ //the comparison loop just need to add an increment line and become: if (usersymbol == symbol) { cout