C# Program issue
Go to solution
Solved by vorticalbox,
right now your code will give you winnings for 2 and 3 matches if you match all 3. I assume this isn't what you're after
if (fruits[0]==fruits[1]||fruits[0]==fruits[2]||fruits[1]==fruits[2])
{
if (fruits[0]==fruits[1]&&fruits[0 ==fruits[2]&&fruits[1]==fruits[2])
{
amountWon = userInput * threeWinners;
resultLabel.Text = amountWon.ToString("C");
totalWon = totalWon + amountWon;
} else
{
//moving the 2 win code to here means you will only win 2 matches or 3 matches not both.
amountWon = userInput * twoWinners;
resultLabel.Text = amountWon.ToString("C");
totalWon = totalWon + amountWon;
}
}else
{
resultLabel.Text = "You didn't win anything.";
}
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now