0

Alright, so the assignment which im sure you guys have seen around alot is to do a powerball type program, 1-55 for the first 5 numbers then the 6th 1-42.

I set up the program, i get my random numbers. but the teacher wants you to assign a single variable and not use global variables.

Im not too sure whats going wrong but i outFiled and inFiled my code and i get a result each time but it DOES NOT save. im so baffled becuase my friend wrote his and it saves perfectly fine.

here is what ive written so far .

any help is appreciated thank you!

```
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
ofstream outFile;
outFile.open("powerball2.txt");
outFile <<"** Powerball **"<<endl<<endl;
srand(int(time(0)));
outFile << 1+rand()%55 <<endl;
outFile << 1+rand()%55 <<endl;
outFile << 1+rand()%55 <<endl;
outFile << 1+rand()%55 <<endl;
outFile << 1+rand()%55 <<endl;
outFile << 1+rand()%42 <<endl<<endl<<endl;
outFile.close();
ifstream inFile;
inFile.open("powerball2.txt");
inFile >> 1+rand()%55 <<endl;
inFile >> 1+rand()%55 <<endl;
inFile >> 1+rand()%55 <<endl;
inFile >> 1+rand()%55 <<endl;
inFile >> 1+rand()%55 <<endl;
inFile >> 1+rand()%42 <<endl;
inFile.close();
system("pause");
return 0;
}
```