Suppose you want to develop a program to play lottery. The program randomly generates a Lottery of a two-digit number, prompts the user to enter a two-digit number, and determines whether the user wins according to the following rule:
If the user matches the lottery in exact order , the awards is $10,000.
If the user input matches the lottery, the awards is $3,000.
If one digit in the user input matches a digit in the lottery, the awards is $1,000.
- I'm having trouble all the numbers that i input it prints out "You matched both numbers. You win $3,000", please help.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int guessNum1,guessNum2,lotteryNum1,lotteryNum2;
double lotramd,userg;
char ans;
srand(time(NULL));
do{
lotramd= rand()%(100)+1;
printf("Dehkhoda Jackpot Lottery\n");
do{
printf("Enter your lottery numbers:");
scanf("%lf",&userg);
if (userg == lotramd)
printf("Exact match! You win $10,000\n");
else if (guessNum2 == lotteryNum1 && guessNum1 == lotteryNum2)
printf("You matched both numbers. You win $3,000\n");
else if (guessNum1 == lotteryNum1
|| guessNum1 == lotteryNum2
|| guessNum2 == lotteryNum1
|| guessNum2 == lotteryNum2)
printf("You matched one digit! You win $1,000\n");
else
printf("Sorry, you did not get any matches!");
}
while(userg != lotramd);
printf("Play Again? (y/n)");
scanf(" %c",&ans);
}while(ans=='y');
return 0;
}