Question

In the "Go" button add 15 random numbers in the array using a random number generator....

In the "Go" button add 15 random numbers in the array using a random number generator. Remove the call to "SetToZero" and the code following. Remove the "SetToZero" method. Add Access Keys of your choice Assign an accept button Assign cancel button (Exit) Add a Button "Find Max" Write an appropriately named method that Accepts the array Finds the largest int and returns the value "Find Max" button click Calls above method Opens a MessageBox to display the returned value Add a Button "Find Min" Write an appropriately named method that Accepts the array Finds the smallest int and returns the value "Find Min" button click Calls above method Opens a MessageBox to display the returned value Code below: public partial class Form1 : Form { public Form1() { InitializeComponent(); } // Click event handler for the goButton control. private void goButton_Click(object sender, EventArgs e) { // Create an int array. int[] numbers = { 1, 2, 3 }; // Display the array in the list box. outputListBox.Items.Add("The array's original contents:"); foreach (int number in numbers) { outputListBox.Items.Add(number); } // Pass the array to the SetToZero method. SetToZero(numbers); // Display the array in the list box again. outputListBox.Items.Add(""); outputListBox.Items.Add("After calling SetToZero:"); foreach (int number in numbers) { outputListBox.Items.Add(number); } } // The SetToZero method accepts an int array as an // argument and sets its elememts to 0. private void SetToZero(int[] iArray) { for (int index = 0; index < iArray.Length; index++) { iArray[index] = 0; } } // Click event handler for the exitButton control. private void exitButton_Click(object sender, EventArgs e) { // Close the form. this.Close(); } private void FindMaxButton_Click(object sender, EventArgs e) { } private void FindMinButton_Click(object sender, EventArgs e) { } } }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C # application to generate 15 random numbers and find max and min values

Step1:

Create a C# windows application with input controls buttons, list box as shown below.

Step2:

Set the properties of the control of the form as shown in below table

Step3:

//Source code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
// Create an int array of size,15
int[] numbers =new int[15];

public Form1()
{
InitializeComponent();
}

/*Double click the Exit button and clos the form*/
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
/*Double click the Go button and write below code to add 15 random numbers
in a range of 1 to 100*/
private void goButton_Click(object sender, EventArgs e)
{
//Clear the list box before adding random numbers to the list
outputListBox.Items.Clear();
// Display the array in the list box again.
outputListBox.Items.Add("");
outputListBox.Items.Add("15 Random Numbers");
// Display the array in the list box.   
Random random = new Random();
for (int index = 0; index < numbers.Length; index++)
{
int randomNumber = random.Next(0, 100);
numbers[index] = randomNumber;
outputListBox.Items.Add(randomNumber);
}   
}
/*
* Double click the FindMax Button and write below code to find
* maximum value in the array.
*/
private void FindMaxButton_Click(object sender, EventArgs e)
{
//Assume that first value is the max value
int maxValue = numbers[0];
for (int index = 1; index < numbers.Length; index++)
{
//update the maxValue
if (numbers[index] > maxValue)
maxValue = numbers[index];
}
//Display the Max Value in a message box
MessageBox.Show("Max value : " + maxValue,
"MessageBox",
MessageBoxButtons.OK,
MessageBoxIcon.Information );
}//end of the method, FindMaxButton_Click


/*
* Double click the FindMin Button and write below code to find
* minimum value in the array.
*/
private void FindMinButton_Click(object sender, EventArgs e)
{
//Assume that first value is the min value
int minValue = numbers[0];
for (int index = 1; index < numbers.Length; index++)
{
//update the minValue
if (numbers[index] < minValue)
minValue = numbers[index];
}
//Display the min Value in a message box
MessageBox.Show("Min value : " + minValue,
"MessageBox",
MessageBoxButtons.OK,
MessageBoxIcon.Information);

} //end of the method, FindMinButton   
}
}


Step4:

Run the program, press F5

Press, Go button

Press "Find Max"

Click on OK

Press the Min button

Add a comment
Know the answer?
Add Answer to:
In the "Go" button add 15 random numbers in the array using a random number generator....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to...

    C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to create a Windows Form Application that will mimics a calculator. This is the screenshot how it shouldl look like. Calculator It should have a textbox and the following buttons: + Addition - Subtraction * Multiplication / Division = Equals (Will perform the final calculation) C Clear (Will clear the text box) There will be no maximize or minimize buttons. The rules are these: 2...

  • C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have...

    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...

  • Program using visual basic.net You will create a very simple two numbers calculator with save options;...

    Program using visual basic.net You will create a very simple two numbers calculator with save options; here is the specifications for the application. Create a form divided vertically in two halves with right and left panels 1- In the left panel you will create the following control, the label or the value of the control will be in "" and the type of the control will in [] a- "First Number" [textbox] b- "Second number" [texbox] c- "Result" [textbox] -...

  • how to add methods into thjs code using C# on visual studio? -validatetextbox should return a true false depending if input is valid -resetinput should clear all input and restart radiobuttons...

    how to add methods into thjs code using C# on visual studio? -validatetextbox should return a true false depending if input is valid -resetinput should clear all input and restart radiobuttons to the defult positions -displaymessge must display messge box to the user displaying such as “5+8=12” calculator.cs x Prearam S Miscellaneous Files ator.Designer.c s Calculato 1 曰using Systemi 2 using System.Collections.Generic; using System.ComponentModel; 4 using System.Data; s using System.Drawing; 6 using System.Linq 7using System.Text; 8 using System.Threading.Tasks; 9 using...

  • Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for...

    Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for values Brands (Samsung, iPhone, Google) Models (Galaxy, Note, 8, X, Pixel) Price ($0.01-$2000) Include a comment about your addition, you can be creative, add components (or not), individualize this. Extra Credit (Samsung must be paired to Galaxy or Note) 2 points Below is the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Cell_Phone_Test {...

  • Consider the following program that reads a number of nonnegative integers into an array and prints...

    Consider the following program that reads a number of nonnegative integers into an array and prints the contents of the array.   Complete the missing parts, add new function prototypes and function definitions, and test the program several times. Add the following to the program: Write a void function that prints the list of nonnegative integers in reverse. Write a void function that prints all the numbers stored in the list that are greater than 10. It will also print the...

  • Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the valu...

    Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...

  • How can I add this function to my C# code?: Validate that if the user clicks...

    How can I add this function to my C# code?: Validate that if the user clicks the “OK” button, a “Seating Category” is selected, and at least one ticket is being purchased. If not, pop-up a dialog box asking the user to enter the needed data for the transaction. What we want to avoid is depicted in See Figure 3. Figure 3: This code asks for a seating category to be selected, how many tickets to be purchased, and if...

  • Programming language C Please go through this carefully. Needs function void add(int *a1, int n, int...

    Programming language C Please go through this carefully. Needs function void add(int *a1, int n, int *a2) Write a program addition.c that reads in an array (a1) of numbers, and creates a new array (a2) of numbers such that the first and last numbers of a1 are added and stored as the first number, the second and second-to-last numbers are added and stored as the second number, and so on. You need to check for even and odd length of...

  • This is done in visual basic langauge. I created a query and i want to invoke this query from code. for example, if i select the Company-owned radio button and hit the display button ONLY the informat...

    This is done in visual basic langauge. I created a query and i want to invoke this query from code. for example, if i select the Company-owned radio button and hit the display button ONLY the information for company owned stores should be shown. same for the other radio button except it will only show the information for the Franchise ownership. F. for Franchises C. for company owned please provide the appropriate code. and select statements. hon Mcescft Vsal Studio...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT