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

I\'m working on this program that will take three variables from the user, put t

ID: 3545976 • Letter: I

Question

I'm working on this program that will take three variables from the user, put those values into three arrays, and then print out those arrays. For the life of me, I can't seem to get this to build. Can anyone explain what's wrong with it for me and how I can fix it?


#include <iostream>

#include <string>


using namespace std;


const int ARSIZE = 400;


void printArrays (int levelsArray[], int scoresArray[], int starsArray[], int i);


int main()

{



int levelsArray[ARSIZE];

int scoresArray[ARSIZE];

int starsArray[ARSIZE];

int i;


cout << "Please enter the level number (-999 to quit): ";

cin >> i;



while(i != -999)

{

i=ARSIZE;


cout << "Please enter the score: ";

cin >> scoresArray[i];


cout << "Please enter the number of stars: ";

cin >> starsArray[i];

cout << "Please enter the level number (-999 to quit): ";

cin >> i;

if (i == -999)

break;

}

return ARSIZE;


printArrays (levelsArray[], scoresArray[], starsArray[]);

{

void printArrays (int levelsArray[], int scoresArray[], int starsArray[], int i)

cout << "Level" << " " << "Score" << " " << "Stars" << endl;

cout << levelsArray[ARSIZE] << " " << scoresArray[ARSIZE] << " " << starsArray[ARSIZE];

}

}



Explanation / Answer

#include <iostream>

#include <string>


using namespace std;

int k=0;

const int ARSIZE = 400;


void printArrays (int levelsArray[], int scoresArray[], int starsArray[]);


int main()

{



   int levelsArray[ARSIZE];

   int scoresArray[ARSIZE];

   int starsArray[ARSIZE];

   int i;


   cout << "Please enter the level number (-999 to quit): ";

   cin >> i;
   while(i != -999)

   {
       levelsArray[k]=i;
       k++;

       cout << "Please enter the score: ";

       cin >> scoresArray[i-1];


       cout << "Please enter the number of stars: ";

       cin >> starsArray[i-1];

       cout << "Please enter the level number (-999 to quit): ";

       cin >> i;

       if (i == -999)

           break;

   }

   //return ARSIZE;


   printArrays (levelsArray, scoresArray, starsArray);
   return 0;
}

void printArrays (int levelsArray[], int scoresArray[], int starsArray[])
{
   int i;
   cout << "Level" << " " << "Score" << " " << "Stars" << endl;
   for(i=0;i<k;i++)
       cout << levelsArray[i] << "     " << scoresArray[levelsArray[i] -1] << "     " << starsArray[levelsArray[i] -1]<<endl;
}