Wondering if anyone could help me with this. this is an homework assignment. won
ID: 3658469 • Letter: W
Question
Wondering if anyone could help me with this. this is an homework assignment. wondering if you could help me code for it
This project consists of two parts: adding support for an output file to an existing program, then converting part or all of that program to use functions and / or arrays.
1. Starting with slot.cpp
you should first build in support for writing output to an output file. You can call the output file anything that you wish. Add comments to the program if needed to make sure that you and anyone that looks at it would completely understand what it is doing and how it works.
2. Make a copy of your existing program and modify the new program to be array based or to use functions or both. Because it is a copy it will have support for writing to an output file. It does not have to work exactly like the original but it must be playable in a similar manner, ie, it can be an improvement upon the original in whatever way you wish. You should implement a minimum of two arrays or functions to receive a grade of 100 for the project. A lower grade will be given for fewer arrays or functions unless several other programming techniques are added such as string handling, switch statements, and so forth.
slot code is /* Slot Machine Program by Joe Tchamitchian*/
#include
#include
#include
using namespace std;
int main()
{
int x,a, b, c, token=4;
srand(time(0));
cout<<" ******************************************************** "
<< " * Welcome to slot machine. * "
<< " * Would you like to play? (1 to play, 2 not to play) * "
<< " ******************************************************** ";
cin>>x;
while(token!=0)
{cout<<"You have "<<token<< " tokens "
<< "Pull? (1 to pull, 2 not to pull) ";
cin>>x;
if(x==1)
{
a = 1+rand() ;
b = 1+rand() ;
c = 1+rand() ;
// b = a;
// c = a;
cout<<" "<<a<<" "<<b<<" "<<c<<" ";
}
else
cout<<"OK ";
{
if(a==b && b==c)
{
token+=4;
cout<<"You win ";
}
else if(a==b || b==c || a==c)
{
token+=1;
cout<<"You got two out of three ";
}
else
{
token-=1;
cout<<"You lose ";
}
}
}
return 0;
}
Explanation / Answer
#include #include #include #include using namespace std; void menu(ofstream&); void update(int arr[],int &token,ofsteam& out); int main() { ofstream out("SlotOutfile.txt");//declare a ofstream and have it open SlotOutfile.txt for writing int x, arr[3], token=4; srand(time(0)); menu(out); cin>>x; while(token!=0) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.