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

19 ( Guess the Number A pp ) <?xml:namespace prefix = o ns = \"urn:schemas-micro

ID: 3553659 • Letter: 1

Question

19 (Guess the Number App) <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>

Develop an app that generates a random number and prompts the user to guess the number. When the user clicks the New Game Button, the app chooses a number in the range 1 to 100 at random. The user enters guesses into the Guess: TextBox and clicks the Enter Button. If the guess is correct, the game ends, and the user can start a new game. If the guess is not correct, the app should indicate whether the guess is higher or lower than the correct number.

Use instance variable for a Random object and to store the randomly generated numbers in the range of 1 to 100. If a guess is correct, display Correct in the Result Label1, then disable the Enter Button and enable the New Game button. If a guess is higher than the correct answer, display Too high

Explanation / Answer

Hey, i am pasting ocde below, plus check below link, Page 285


http://uqu.edu.sa/files2/tiny_mce/plugins/filemanager/files/4290078/operation_research/c_sharp_programming/Instructors%20Manual%20for%20Simply%20C%20Sharp%20-1.pdf





// GuessNumber.cs


using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;


namespace GuessNumber

{

/// <summary>

/// Summary description for FrmGuessNumber.

/// </summary>


public class FrmGuessNumber : System.Windows.Forms.Form

{

// Label to display directions

private System.Windows.Forms.Label lblQuestion;


Label and TextBox to input a number as a guess

private System.Windows.Forms.Label lblGuessNumber;

private System.Windows.Forms.TextBox txtGuessNumber;


// Labels to display result of guess

private System.Windows.Forms.Label lblResult;

private System.Windows.Forms.Label lblResultLabel;


// Button to enter a guess

private System.Windows.Forms.Button btnEnter;

// Button to begin a new game

private System.Windows.Forms.Button btnNewGame;

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.Container components = null;



public FrmGuessNumber()

{

//

// Required for Windows Form Designer support

//

InitializeComponent();


//

// TODO: Add any constructor code after InitializeComponent

// call

//

}


/// <summary>

/// Clean up any resources being used.

/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}


// Windows Form Designer generated code


/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main()

{

Application.Run( new FrmGuessNumber() );

}


// Load Form event

private void FrmGuessNumber_Load( object sender, System.EventArgs e )

{

m_intNumber = m_objRandom.Next( 1, 101 );

} // end FrmGuessNumber_Load


// handles Enter Button's Click event

private void btnEnter_Click( object sender, System.EventArgs e )

{


// check answer

if ( Int32.Parse( txtGuessNumber.Text ) == m_intNumber )

{

lblResult.Text = "Correct!";

btnEnter.Enabled = false;

btnNewGame.Enabled = true;

}

else if ( Int32.Parse( txtGuessNumber.Text ) > m_intNumber )

{

lblResult.Text = "Too high...";

}

else

{

lblResult.Text = "Too low...";

}


txtGuessNumber.Clear();

txtGuessNumber.Focus();


} // end method btnEnter_Click


// handles New Game Button's Click event


private void btnNewGame_Click( object sender, System.EventArgs e )

{

// generate new random number

m_intNumber = m_objRandom.Next( 1, 101 );

btnEnter.Enabled = true;

btnNewGame.Enabled = false;

lblResult.Text = ""; // clear result;

} // end method btnNewGame_Click

} // end class FrmGuessNumber

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote