i need the codes for this visual basic program. please answer this ASAP 3. (4 po
ID: 3607508 • Letter: I
Question
i need the codes for this visual basic program. please answer this ASAP
3. (4 points) Using a loop of your choice write a program that implements a number guessing game. (The number to be guessed is hard coded into the program e.g. magic_number 57.) Use an Input Box that prompts the user to guess a number between 1 and 100. Then the program will check the guess to see if it matches the number. If the guess is too low the player will be told by a message box that their guess is too low and they will be given a chance to enter a new guess. Similarly, if they enter a number that is too high they will be told that their guess is too high and they will be given a chance to enter another guess. When they guess the number exit the loop and use a message box to inform the user with "Congratulations! You Win!" Example Output. Problem 3 Problem_:3 Guess the magic number between 1 and 100, or enter "QUIT " to stop OK Sorry that is too low. Try again OK Problem 3 Problem_3 Guess the magic number between 1 and 100, or enter "QUIT "to stop OK Congratulations! You win!! 57 OKExplanation / Answer
1st ans
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Test1 : Form
{
public Test1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (txtNum1.Text == "")
{
MessageBox.Show("Enter the number please");
}
else
{
double a;
double.TryParse(txtNum1.Text, out a);
{
while (a >= 1 && a <= 100)
{
if (a == 57)
{
MessageBox.Show("Congratulations! You win!!");
}
else
{
if (a <= 40)
{
MessageBox.Show("sorry that is too low.Try again.");
}
else if (a >= 65)
{
MessageBox.Show("sorry that is too high.try again.");
}
if (a > 40 && a < 57)
{
MessageBox.Show("sorry but your are very near to magic number");
}
else if (a > 57 && a < 65)
{
MessageBox.Show("sorry but your are very near to magic number");
}
} break;
}
if (a>100 && a<1)
{
MessageBox.Show("enter a valid input.");
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
2 ans i cannot know rhr i.e, resting heart rate.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.