Question

In: Computer Science

Debug the following program.Each line that has a number and line at the end of it...

Debug the following program.Each line that has a number and line at the end of it has an error. The error can be syntax or logic. Correct the error. Rewrite the correct answer in place of the original code :

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

{

intLimit = zero; //

intCounter == 1; // counter need to begin at 1

lstResults.Items.Empty(); // clear ListBox

intLimit = Int32.Parse( txtInput); // retrieve user input from GUI

lstResults.Items.Add( "N/tN^2/tN^3" ); // add header with tabs

calculate and display square and cube of 1 to intLimit

while ( intCounter <= intLimit ) ;

lstbx.Items.Add( intCount = "\t" + Math.Pow( intCount, 2 );

Math.Pow( intCount 3^ );                   

intCount++;                                                        // increment counter

}

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Windows Forms Application in C# is created using Visual Studio 2017 with name "WindowsFormsApp7".This application contains a form with name "Form1.cs".Below are the files associated with form1.

1.Form1.cs[Design]

2.Form1.cs

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 WindowsFormsApp7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//calculate button click
private void btnCalculate_Click(object sender, EventArgs e)
{
int intLimit = 0; //declare a variable
int intCounter = 1; // counter need to begin at 1
lstResults.Items.Clear(); // clear ListBox
intLimit = Int32.Parse(txtInput.Text); // retrieve user input from GUI
lstResults.Items.Add("N\tN^2\tN^3"); // add header with tabs
//calculate and display square and cube of 1 to intLimit
while (intCounter <= intLimit)
{
//find square and cube and add it in the listbox
lstResults.Items.Add(intCounter + "=\t" + Math.Pow(intCounter, 2)+"\t"+Math.Pow(intCounter,3));
intCounter++; // increment counter
}


}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :

Screen 2 :Screen showing squares and cubes

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

The distribution of the number of people in line at a grocery store checkout has a...
The distribution of the number of people in line at a grocery store checkout has a mean of 3 and a variance of 9. A sample of the numbers of people in 50 grocery store checkout lines is taken. (a) (3 points) What’s the probability that the sample mean is less than 4.5? Round your answer to four (4) decimal places. (b) (3 points) What’s the probability that the sample mean is more than 2.25? Round your answer to four...
The distribution of the number of people in line at a grocery store has a mean...
The distribution of the number of people in line at a grocery store has a mean of 3 and a variance of 9. A sample of the numbers of people in line in 50 stores is taken. (a) Calculate the probability that the sample mean is more than 4? Round values to four decimal places. (b) Calculate the probability the sample mean is less than 2.5. Round answers to four decimal places. (c) Calculate the probability that the the sample...
makes it in c++ Kyal is in line at the DMV he has number 325, they...
makes it in c++ Kyal is in line at the DMV he has number 325, they are currently serving customer 320. Use a switch statement to determine which type of loop he needs to use to count to his turn being called. f = for loop w = while loop d = do-while loop Output the appropriate loop type from the switch. Then use any loop type to get from 320 to 325. Select the appropriate loop type f= for,...
Use the following data for number of streamed films, on-line in a month to 9 4...
Use the following data for number of streamed films, on-line in a month to 9 4 13 10 5 10 13 14 19    4 10 16 9 11 14 8 15 7    10 11 9 7 6 12 12 14 16 15 14 9 19 3 9 16 19 15 a) make a frequency distribution b) calculate the number of groups c) calculate the group width d) complete the following chart (use as many or as few spaces...
Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the...
Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the HTML file that references the JavaScript file. Use prompt to collect names of persons from the user. When the user enters ‘DONE’, your script should stop collecting more names. Then, it should ask the user to specify the following style properties: Border size? 2px, 5px, or 8px. Border Color? blue, red, green, and black. Border style? solid, dotted, dashed, and double. The HTML document...
B. Manually analyze and debug the following logic and programming code. Write in the result column,...
B. Manually analyze and debug the following logic and programming code. Write in the result column, the value of the result variable when the variables i and j have the values ​​indicated in each row of the table (6 pts.). In the event that the result cannot be calculated, state it and the reason. Option Explicit Sub Calc () Dim i As Integer, j As Integer, n As Integer Dim result As Integer i = 0 j = 0 n...
Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the...
Write, test, and debug (if necessary) JavaScript scripts for the following problem. You must write the HTML file that references the JavaScript file. Use prompt to collect names of persons from the user. When the user enters ‘DONE’, your script should stop collecting more names. Then, it should ask the user to specify the following style properties: - Border size? 2px, 5px, or 8px. - Border Color? blue, red, green, and black. - Border style? solid, dotted, dashed, and double....
A line of high-end tires produced by a large company has a wear-out life that can...
A line of high-end tires produced by a large company has a wear-out life that can be modeled using a normal distribution with a mean of 25,000 miles and a standard of 2,000 miles. Determine each of the following a- -The percentage of tires that can be expected to wear-out within +or- (plus or minus) 2,000 miles of the average (for example between 23,000 miles and 27,000) b- -The percentage of tires that can be expected to fail between 26,000...
Into to PythonInstructions: • In this lab you are to debug the code found at...
Into to PythonInstructions: • In this lab you are to debug the code found at the end of these instructions: Find and correct all problems found in the code. Create comments in the code explaining what you found and how you corrected it • The purpose of this program is to calculate car insurance rates using the following rules: The base rate of insurance is $50 a month, Males pay a 25% premium over the base rate, Drivers in Michigan...
1) The number of times that student takes an A class, X(X has a line under)...
1) The number of times that student takes an A class, X(X has a line under) has the discrete uniform pmf: p(x) = 0.25 for x = 1,2,3,4. Recall from earlier course material that this pmf has E(X)(X has a line under)=5/2 and V(X)(X has a line under)= 15/12. A random sample of 36 students will be selected and the number of times that have taken A class will be recorded. -Determine the probability that the mean of this sample...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT