Question

In: Computer Science

C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017...

C#

What to submit:

One zip file named Ass3.zip

This zip must contain one VS 2017 solution named Ass3, which contains one C# Windows Forms App project also named Ass3 and the project contains a default form, Form1.cs and Program.cs.

No change should be made in Program.cs, but your Form1 must be designed and implemented to satisfy the following requirements.

**Do not submit only a single file of the solution or project. The whole solution folder of VS 2017 must be zipped and submitted for grading.

Requirements:

  1. Use VS 2017 to create a C# Windows Forms App project whose solution and project are named Ass3. When all requirements below are finished and tested, zip the entire solution as Ass3.zip and upload it for grading.
  2. Use the same Functional Requirement as described in Assignment 2 with the changes below.
  3. Except the Form1 class given by Visual Studio, no other classes need to be defined. That is, the program you did in Assignment 2, including data and methods of the two classes should be "transplanted" in the Form1 class of this Ass3 project.
  4. All input and output should be done within Form1 and visual controls (e.g., textboxes, labels, buttons, etc.) on the form. That is, no console is used--no more command line I/O and no display in the Command Prompt.
  5. Specifically, the two initial integers and each guess should be entered in a corresponding textbox (i.e., three textboxes in total) and the error message "You must enter a number between ... and ...!" will be displayed by a label in red. A second label should be used to display in blue the hint "Higher...", "Lower...", and "You win!". Finally, let the ending message "----End of Game----" be displayed in the form title (in black since title color cannot be changed).
  6. Set the font size of all visual controls to be 18 points.
  7. Add a button showing 'Generate Secrete Number' to create a secrete number every time it is clicked. Because this button can be clicked at any time, there might be an error or hint displayed from the previous play, this button should also erase both labels to empty and reset the form title to 'Form1' when clicked.
  8. To accept a guess, a second button showing 'Guess' should be added on the form. Each time when it is clicked, it first erases the labels from their previous display and then show the error and/or hint message, depending on the guess entered.
  9. Place each visual control in Form1 so they look like the form shown in the demo program attached below.
  10. Same as in Assignment 2, we assume there are always two valid input integers entered to define the range of the random secrete number, and an integer is always entered as the guess value. That means there is no need to validate all three input integers except the guess value could still be out of the range, which explains (in item 5 above) why an error message needs to be displayed.

Solutions

Expert Solution

Using VS 2017 created a C# Windows Forms App project whose solution and project are named Ass3.

Form1.cs[Design]:

Form1.cs:

//namespaces
using System;
using System.Drawing;
using System.Windows.Forms;
//project namespace
namespace Ass3
{
public partial class Form1 : Form
{
//in C# Random class is used to created random number between range of values
//creating object of Random class
Random random = new Random();
//generate secrete number that is called as random number
int randNumber = 0;   
public Form1()
{
InitializeComponent();
}
//Generate Secrete Number number, when this button clicked random number will be generated
private void btnGenerateSecreteNumber_Click(object sender, EventArgs e)
{
this.Text = "Form1";//set form title
//get min and max range entered by user and generate number between min and max range   
randNumber = random.Next(int.Parse(txtLowRange.Text), int.Parse(txtHighRange.Text));
//clear labels
lblError.Text = "";
lblHint.Text = "";
}
//When guess button clicked this event will be triggered.
private void btnGuessTheNumber_Click(object sender, EventArgs e)
{
//clear labels
lblHint.Text = "";
lblError.Text = "";
//below is the guess number entered by user and storing it in the variable guessUser
//before storing parsing number to integer
int guessUser = int.Parse(txtGuessTheNumber.Text);
//checking whether guess number entered by user is valid or not
if (guessUser < int.Parse(txtLowRange.Text) || guessUser > int.Parse(txtHighRange.Text))
{
//when guess is not valid then show error if guess is not in the range
//show message first
lblError.Text = "You must enter a number between " + txtLowRange.Text + " and " + txtHighRange.Text + "!";
//then change the color of the label
lblError.ForeColor = Color.Red;
}
else
{
//checking user entered guess with generated random number
if (guessUser < randNumber)
{
//if guess entered by user is less than generated random number then display message
lblHint.Text = "Lower...";//set text first
lblHint.ForeColor = Color.Blue;//then change color to blue
}
//checking if guess number entered by user is greater than random number
else if (guessUser > randNumber)
{
//if guess is higher than generated random number then display message
lblHint.Text = "Higher...";//set text
lblHint.ForeColor = Color.Blue;//set color
}
//if guess is equal to randNumber
else if (guessUser == randNumber)
{
//if guess is equal to randNumber then display message
lblHint.Text = "You win!";//set text
lblHint.ForeColor = Color.Blue;//set color
//change form title
this.Text = "----End of Game----";
}


}
}
}
}
===============================

Screen 1:Invalid guess

Screen 2:lower guess

Screen 3:higher guess

Screen 4:exact guess


Related Solutions

C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017...
C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017 solution named Ass3, which contains one C# Windows Forms App project also named Ass3 and the project contains a default form, Form1.cs and Program.cs. No change should be made in Program.cs, but your Form1 must be designed and implemented to satisfy the following requirements. **Do not submit only a single file of the solution or project. The whole solution folder of VS 2017 must...
C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017...
C# What to submit: One zip file named Ass3.zip This zip must contain one VS 2017 solution named Ass3, which contains one C# Windows Forms App project also named Ass3 and the project contains a default form, Form1.cs and Program.cs. No change should be made in Program.cs, but your Form1 must be designed and implemented to satisfy the following requirements. **Do not submit only a single file of the solution or project. The whole solution folder of VS 2017 must...
Submit a c++ file: 2. Write a program that defines the named constant PI, const double...
Submit a c++ file: 2. Write a program that defines the named constant PI, const double PI = 3.14159;, which stores the value of p. The program should use PI and the functions listed in Table 6-1 to accomplish the following: a. Output the value of Pi Output the value of Pi. b. Prompt the user to input the value of a double variable r, which stores the radius of a sphere. The program then outputs the following: i.   The...
using C thank you Must submit as MS Word file with a screenshot of the 3...
using C thank you Must submit as MS Word file with a screenshot of the 3 outputs. Run your program 3 times. the output must be in a screenshot not typed for the each time you run the program. thank you Modify the code below to implement the program that will sum up 1000 numbers using 5 threads. 1st thread will sum up numbers from 1-200 2nd thread will sum up numbers from 201 - 400 ... 5th thread will...
Write a Python script that performs brute force to extract a password protected zip file named...
Write a Python script that performs brute force to extract a password protected zip file named sec2.zip. The password is believed to be associated with one of the dictionary word in the 'wordlist.txt file. a) Paste your code here b) What is the password?
Create one Excel file to submit named "Exam 3 Team X.xlsx" where X is your team...
Create one Excel file to submit named "Exam 3 Team X.xlsx" where X is your team letter. Show work for credit. USE EXCEL 1. Use the data below. Team C Date DOW 10YTREAS 8-Apr-20 23,719.37 0.729 1-Apr-20 22,653.86 0.736 25-Mar-20 21,917.16 0.698 18-Mar-20 20,704.91 0.816 11-Mar-20 21,237.38 0.997 4-Mar-20 25,018.16 0.748 26-Feb-20 25,917.41 1.01 19-Feb-20 27,081.36 1.33 12-Feb-20 29,232.19 1.556 5-Feb-20 29,276.34 1.59 29-Jan-20 28,807.63 1.603 22-Jan-20 28,722.85 1.641 15-Jan-20 29,196.04 1.769 8-Jan-20 28,939.67 1.818 1-Jan-20 28,583.68 1.827 a. Create...
Create a C++ login program using file for 2 user. Usernames must be in one file...
Create a C++ login program using file for 2 user. Usernames must be in one file and password in the other file. Ask user for their usernames and password if it matches, they logged in successfully. If it doesn’t match,they have 3 trials ,then they have to sign in and create a username and password. After creating a username and password, they have to go to the login page again. Must work for visual studio code
Create a CodeBlocks project with a main.cpp file. Submit the main.cpp file in Canvas. C++ Language...
Create a CodeBlocks project with a main.cpp file. Submit the main.cpp file in Canvas. C++ Language A Game store sells many types of gaming consoles. The console brands are Xbox, Nintendo, PlayStation. A console can have either 16 or 8 gigabytes of memory. Use can choose the shipping method as either Regular (Cost it $5) or Expedite (Cost is $10) The price list is given as follows: Memory size/Brand Xbox Nintendo PlayStation 16 gigabytes 499.99 469.99 409.99 8 gigabytes 419.99...
Name your functions countOnesLoop() and countOnesWhere() and submit your code in a file named countOnes.py. Write...
Name your functions countOnesLoop() and countOnesWhere() and submit your code in a file named countOnes.py. Write a function that consists of a set of loops that run through an array and count the number of ones in it. Do the same thing using the where() function (use info(where) to find out how to use it) (in python)
Write a C++ program to create a text file. Your file should contain the following text:...
Write a C++ program to create a text file. Your file should contain the following text: Batch files are text files created by programmer. The file is written in notepad. Creating a text file and writing to it by using fstream: to write to a file, you need to open thew file as write mode. To do so, include a header filr to your program. Create an object of type fsrteam. Open the file as write mode. Reading from a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT