Create an application with the following requirements:
Please do it in visual studio C # and post copy of form.cs and program.cs. Will give vgood review!!!
Below is the solution:
code:
using System;
using System.Windows.Forms;
namespace GuessNumber
{
public partial class GuessNumber : Form
{
int randomNumber,
num;
Random randm = new
Random();
public
GuessNumber()
{
InitializeComponent();
}
private void
btnCheck_Click(object sender, EventArgs e)
{
//MessageBox.Show(randomNumber.ToString());
if (!int.TryParse(txtGuess.Text, out num)) //chcek for the numeric
input
{
MessageBox.Show("Enter number only");
}
else if (num < 1 || num > 100)
{
MessageBox.Show("Please enter the guess number between
1-100");
}
else if (num == randomNumber)
{
lblResult.Text = "Congratulations you win.".ToString();
randomNumber = randm.Next(1, 100); //gerate new random number for
the new guess
txtGuess.Text = ""; //clear the textbox
txtGuess.Focus(); //focus the cursor on textbox
}
else if (num < randomNumber)
{
lblResult.Text = "Wrong Guess....\nThe number is too
low".ToString();
}
else if (num > randomNumber)
{
lblResult.Text = "Wrong Guess....\nThe number is too
high".ToString();
}
//MessageBox.Show(randomNumber.ToString());
}
//help event to see
the correct number
private void
btnHelp_Click(object sender, EventArgs e)
{
MessageBox.Show("The correct guess number is:
"+randomNumber.ToString());
}
//form load
event
private void
GuessNumber_Load(object sender, EventArgs e)
{
lblResult.Text = "GUESS NUMBER???".ToString();
Random randm = new Random();
randomNumber = randm.Next(1, 100);
lblMessage.Text = "Guess the secret number";
}
}
}
output:
form has shown the check your guess event in label and Help event in message box
program.cs:
using System;
using System.Windows.Forms;
namespace GuessNumber
{
static class Program
{
///
<summary>
/// The main entry point
for the application.
///
</summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
GuessNumber.Designer.cs
namespace GuessNumber
{
partial class GuessNumber
{
private
System.ComponentModel.IContainer components = null;
/// <param
name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void
Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form
Designer generated code
private void
InitializeComponent()
{
this.lblResult = new System.Windows.Forms.Label();
this.btnCheck = new System.Windows.Forms.Button();
this.txtGuess = new System.Windows.Forms.TextBox();
this.lblMessage = new System.Windows.Forms.Label();
this.btnHelp = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lblResult
//
this.lblResult.AutoSize = true;
this.lblResult.Font = new System.Drawing.Font("Microsoft Sans
Serif", 9F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblResult.Location = new System.Drawing.Point(43, 196);
this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(149, 15);
this.lblResult.TabIndex = 9;
this.lblResult.Text = "SECRET NUMBER???";
//
// btnCheck
//
this.btnCheck.Location = new System.Drawing.Point(143, 110);
this.btnCheck.Name = "btnCheck";
this.btnCheck.Size = new System.Drawing.Size(137, 23);
this.btnCheck.TabIndex = 8;
this.btnCheck.Text = "Check Your Guess!";
this.btnCheck.UseVisualStyleBackColor = true;
this.btnCheck.Click += new
System.EventHandler(this.btnCheck_Click);
//
// txtGuess
//
this.txtGuess.Location = new System.Drawing.Point(46, 80);
this.txtGuess.Name = "txtGuess";
this.txtGuess.Size = new System.Drawing.Size(234, 20);
this.txtGuess.TabIndex = 7;
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans
Serif", 9F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMessage.Location = new System.Drawing.Point(43, 32);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(167, 15);
this.lblMessage.TabIndex = 6;
this.lblMessage.Text = "Guess the secret number";
//
// btnHelp
//
this.btnHelp.Location = new System.Drawing.Point(210, 139);
this.btnHelp.Name = "btnHelp";
this.btnHelp.Size = new System.Drawing.Size(70, 23);
this.btnHelp.TabIndex = 10;
this.btnHelp.Text = "Help";
this.btnHelp.UseVisualStyleBackColor = true;
this.btnHelp.Click += new
System.EventHandler(this.btnHelp_Click);
//
// GuessNumber
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(317, 261);
this.Controls.Add(this.btnHelp);
this.Controls.Add(this.lblResult);
this.Controls.Add(this.btnCheck);
this.Controls.Add(this.txtGuess);
this.Controls.Add(this.lblMessage);
this.Name = "GuessNumber";
this.Text = "Guess Number";
this.Load += new System.EventHandler(this.GuessNumber_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private
System.Windows.Forms.Label lblResult;
private
System.Windows.Forms.Button btnCheck;
private
System.Windows.Forms.TextBox txtGuess;
private
System.Windows.Forms.Label lblMessage;
private
System.Windows.Forms.Button btnHelp;
}
}
Create an application with the following requirements: 1 form graphic on the form itself, along with...
C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...
Please create the following pizza order form. My form images are not needed but I can supply them for you. Please be creative with your form. Pizza Order FormCalculate Order Total Clear Order When the Calculate Order Total button has been clicked, do the following: Verify that the Customer Name and Phone Number are not blank. Display an appropriate message if either textbox is empty and place the cursor in the appropriate textbox. Verify that at least one Pizza Choice...
Create an order entry screen program in C# to give a total for an individual pizza order. The Pizza order should have radio buttons for small $7, medium $9, and large $12 choices for the pizza. There should be a checkbox for drink (where a drink is $2 added if it is checked and nothing added if it is not checked. Include a textbox for the customer’s name. Have a button to calculate the subtotal (pizza choice and whether there...
create an application in VISUAL BASIC that calculates a cars gas mileage. The formula for calculating the miles that a car can travel per gallon of gas is MPG = Miles/Gallon In the formula MPG is miles-per-gallon, miles is the number of miles that can be driven on a full tank of gas, and gallons is the number of gallons that the tank holds. The applications form should have TextBox controls that let the user enter the number of gallons...
Use visual studios language C++ to creat Form1 and Designer Form for question below 3. Form has three textboxes, two for input and one for output. Form also has five buttons, marked, ‘+’, ‘-’, ‘*’, ‘/’, ‘C’ respectively. User enters integers into the two textboxes, and clicks one of the four buttons (+, - , *, /). The third textbox shows the result of the corresponding operation. For example, if user entered 10 into the first textbox and 2 into...
Project 2 Description Create a Visual C# project that when an employee's biweekly sales amount is entered and the Calculate button is pressed, the gross pay, deductions, and net pay will be displayed. Each employee will receive a base pay of $1200 plus a sales commission of 8% of sales. Once the net pay has been calculated, display the budget amount for each category listed below based on the percentages given. base pay = $1200; use a named...
Hello! we are using Python to write this program. we are supposed to use loops in this assignment. I would greatly appreciate the help! Thank you! Write a program that allows the user to play a guessing game. The game will choose a "secret number", a positive integer less than 10000. The user has 10 tries to guess the number. Requirements: we would have the program select a random number as the "secret number". However, for the purpose of testing...
Visual Basic Programming Step 1-2 not important, it's just file naming. 3. Form contains nine Labels, one TextBox, and three Button controls. You use labels to let user know what to enter and what will be displayed; TextBoxes to input a number between 1 and 99. Buttons to Calculate change. Clear Input and Exit program. See below Form Layout with Controls for more details 4. Declare variables to store the entered value in TextBox, and what will be displayed in...
Has to be written in C++. Visual studio. Write a C++ program to realize the game of guessing the number. Generally, the game will generate a random number and the player has to find out the number. In each guess, the program will give you a feedback as your guess is correct, too large, or too small. Then the player play repetitively until find out the number. Specifically, the game plays as the following. a). When the game is started,...
Can someone upload a picture of the code in matlab Write a "Guess My Number Game" program. The program generates a random integer in a specified range, and the user (the player) has to guess the number. The program allows the use to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again The basic algorithm is: 1. The program starts by printing instructions on the...