Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use at least one user defined class in your program. Write a program to have the

ID: 3673241 • Letter: U

Question

Use at least one user defined class in your program. Write a program to have the computer generate a digit between 100 and 999. Then the user will try to guess the number. Every time a guess is made, the computer responds with the number of red, yellow, and green digits in the guess. A guess digit is green if the guess digit and the corresponding digit are the same. A guess digit is red if it does not correspond to any of the digits. A yellow guess is if it is a correct digit but not in the correct place. Suppose the computer's number is 123. Your output may look as follows: Please enter a guess? 422 You have: 2 red 1 green 0 yellow Enter the next guess? 459 You have: 3 red 0 green Oyellow Enter the next guess? 122 You have: 1 red 2 green 0 yellow Enter the next guess? 123

Explanation / Answer

/* RedYellowGreen.cpp the computer generates a number between 100-999 then asks the user to guess the number. The computer responds with the number of red, yellow, and green digits of the guess. red = wrong integer guess green = correct integer yellow = correct integer, wrong placement */ #include "stdafx.h" #include #include #include using namespace std; int compare(int RANDOM_NUM, int USER_NUM); int one(int NUM); int ten(int NUM); int hundred(int NUM); void output(int red, int green, int yellow); void main(){ int RANDOM_NUM; int USER_NUM = 1; int RESULT = 0; srand((unsigned)time(NULL)); RANDOM_NUM = rand()%900+100; //generates random number between 100-999 cout