- #1
issacnewton
- 1,000
- 29
Hello
I am writing a program where program will randomly generate a three digit number from 100 to 999 and then user will be asked to guess that number. If the number is matched exactly, then the highest prize is given to the user, if all digits in a guess are also in the original number, next highest prize will be given to the user. If two digits from guess are correct, then the next prize . If one digit from the guess is correct, then the next one. Finally no prize for the guess where no digits match.
I tried to use if-else construct for this. I am able to get the first two correct. But I am having problems with logic where guess might have two of its digits correct and where guess might have only single digit correct. Any specific ideas ?
thanks
IssacNewton
I am writing a program where program will randomly generate a three digit number from 100 to 999 and then user will be asked to guess that number. If the number is matched exactly, then the highest prize is given to the user, if all digits in a guess are also in the original number, next highest prize will be given to the user. If two digits from guess are correct, then the next prize . If one digit from the guess is correct, then the next one. Finally no prize for the guess where no digits match.
I tried to use if-else construct for this. I am able to get the first two correct. But I am having problems with logic where guess might have two of its digits correct and where guess might have only single digit correct. Any specific ideas ?
thanks
IssacNewton