I'm working on this project and I'm REALLY close, I'm just gettin a C2059 error and I have no idea why?
#include <iostream>
using namespace std;
int main()
{
int guess;
int die;
float total = 10;
char ans;
cout << "Welcome to Dice Roll!" << endl;
cout << "Your bank total is: $" << total << ".00" << endl;
cout << "\nGuess the next roll! It costs $1.00 to play!" << endl;
cout << "The correct guess nets you $100.00!\n" << endl;
cin >> guess;
do
{
--total;
die = (int)(rand() % 6) + 1;
if(guess < 1 || guess > 6)
{
cout << "Invalid Input" << endl;
cout << "Try again? (Type 'Y' or 'N')" << endl;
cin >> ans;
}
if(guess == die)
{
cout << "Congratulations! The dice rolled a" << die << "You won $100.00!" << endl;
cout << "\nYour bank total is: $" << total + 100 << ".00" << endl;
cout << "Try again? (Type 'Y' or 'N')" << endl;
cin >> ans;
}
if (guess != die)
{
cout << "I'm sorry, but you lost and we now have your dollar." << endl;
cout << "\nYour bank total is: $" << total << ".00" << endl;
cout << "Try again? (Type 'Y' or 'N')" << endl;
cin >> ans;
} while(ans == 'Y' || 'y');
if (ans != 'Y' || ans != 'y' || ans != 'N' || ans != 'n')
{
cout << "Invalid Input" << endl;
}
else
{
cout << "Thanks for playing! Your bank is $" << total << ".00" << endl;
}
}
return 0;
}
1>Compiling...
1>Lab9.cpp
1>c:\users\stephon.stephon-pc\documents\visual studio 2008\projects\lab9\lab9\lab9.cpp(51) : error C2059: syntax error : 'return'