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

This is part of a group project. It\'s a \"lottery program\" where up to 200 con

ID: 3835475 • Letter: T

Question

This is part of a group project. It's a "lottery program" where up to 200 contestants are allowed to play. As you can see on my program, if the numbers they insert match with the winning numbers, they'll win different prizes (depending on how many numbers they matched). I have to create a separate text file that includes the name of the contestant, what numbers they picked and their prize (if any). My problem is, when I create the separate text file, it displays Player 1, Player 2.. but I would like to have the name the user and the numbers they picked (I just have the numbers of matches but not what actual numbers they plugged in). Moreover, because is part of a project I should make it a user defined function, I'm a little confused on how to do it. My part only requires me to create a separate text file with the information, so how can I make my part work independently of the other people's code?
Thank you so much for your help :( Moreover, because is part of a project I should make it a user defined function, I'm a little confused on how to do it. My part only requires me to create a separate text file with the information, so how can I make my part work independently of the other people's code?
Thank you so much for your help :(
I'm attaching a picture of my code, and the text file. Thank you again! CAWindowslsystem32Acmd.exe Please enter the number of players that participate in game Enter the 5 nunbers for player 0 12 36 Enter the 5 numbers for player 1 23 here 0 herei here here3 here4 here ii0 hereili0 here iv0 here iv0 here iv0 here iu0 here iv0 here iii0 here iv0 here iv0 here iv0 here iv0 here iu0 hereili0 here ivo here ivo here iv0 here iv0 here iv0 hereii here ivo here i here iv0 her e 0 here iv0 here iii0 here iv0 here iv0 here iv0 here iv0 here iv0 here ii1 her e ili here ivi here iv1 here iv1 here ivi here ivi here iiii here ivi here iv1 he re ivi here ivi here ivi, here ili1 here iv1 here iv1 here ivi here ivi here ivi h ere ili1 here ivi here iv1 here ivi here iv1 here iv1 hereili1 here iwi here iv1 here ivi here iwi here ivi Press any key to continue

Explanation / Answer

Here is user defined method for writting player information in a file.

Please note if you want to store all player info at once, you need to do store names of player in an array as well.

// players string array for name, numbers contain number choosen by user, n is number of players
void writeDataToFile(string players[], int numbers[][5], int n)
{
ofstream out("playerdata.txt");
out << n << endl;
for(int i = 0; i < n; i++)
{
out << players[i] << endl;
for(int j = 0; j < n; j++)
{
out << numbers[i] << " ";
}
out << endl;
}
out.close();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote