?? loop, seperating parts, random numbers. lets play a game...

so i was given an assignment and i cant get it to function the correct way, it is due tomorrow night and I have been burning my wheels trying to get this things to work. can someone please help me..


//////////////////////////////////////////////
/* input – One character.

Process – “Spin” the wheel. Add or subtract to the bank based on the spin. Don’t let the user play unless their bank is $10 or more.

Output – Initially explain the game (see text below) once. Tell the user the amount their bank is, ask if they would like to spin, if yes show the spin and win/lose amount and new value in bank after the spin. When the user doesn't play again or their bank drops below $10 thank them and tell them to come play again as shown in the sample output below.

Your program should look something like this:

Come play "Spin the Wheel." The wheel has numbers from 1-10.

If you spin an even number you lose that amount. If you spin an

odd number you win that amount. You start with a $25 bank.



Your bank is: $25. Would you like to spin the wheel? (y/n): Y

You spun a 3 and won $3!

Your bank is now: $28



Would you like to spin again? (y/n): y

You spun a 7 and won $7!

Your bank is now: $35



Would you like to spin again? (y/n): n

Thanks for playing! Come back soon!

Press any key to continue . . .



Note the differences between the first and second paragraphs and the third and every following paragraph in the sample output. Build you program similarly. */

/////////////////////////////////////// HERE IS MY CODE

#include <iostream>
#include <ctime>

using namespace std;



int main()
{
int num = rand() % 10 + 1;
int srand(static_cast <unsigned int> (time(0)));

char answer;
cout << " come play spin the wheel. the wheel has numbers from 1 to 10." << endl;
cout << " if you spin an even number you lose that amount." << endl;
cout << "odd number will win that amount. You start with a $25 bank." << endl;
cout << endl;
cout << " your bank is $25: would you like to spin the wheel? (y/n)";
cin >> answer;
num = rand() % 10 +1, num++;

while (toupper(answer) == 'Y')
{
int banktot = 25.00;
{

if (num % 2 != 0)
{
cout << " you spun a " << num << " you won $" << num << endl << "bank = " << banktot + num << endl;
}
else if (num % 2 == 0)
{
cout << "you spun a " << num << " you lost $" << num << endl << "Bank = " << banktot - num << endl;
}

{
if (banktot + num > 10 || banktot - num > 10)
cout << "Would you like to play again (y/n)" << endl;

else (banktot + num < 10 || banktot - num > 10);
cout << "Game over" << endl;
}
break;
}


}
return 0;

}
Last edited on
closed account (48T7M4Gy)
Put in code blocks and use proper indentation please.
Topic archived. No new replies allowed.