Question

In: Computer Science

Problem 6.3 Sum of Numbers - Similar to Problems 6.1 & 6.2, you must sum up...

Problem 6.3 Sum of Numbers - Similar to Problems 6.1 & 6.2, you must sum up 5 numbers. However, you will obtain these numbers from a list box for which you have used the String Collection Editor to insert a number on each of 5 lines in the box. You may use any type of loop. The result is displayed in a text box. The program is initiated with "Go" button.

Problem 6.3 does NOT require an Input Dialog Box. Instead, YOU the PROGRAMMER put a list box control on the form. The PROGRAMMER loads up the list box at design time with all five (5) numbers to be summed.

Solutions

Expert Solution

Step1: Create a C# WindowsFormApplication and set a name of your choice.

Step2: Design the form with ListBox, Button and TextBox as shown in the below screenshot

Step3:

Set the following properties of the controls on the form

Step4:

Double click the Go button and write the below code

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 SumupCollection
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnGo_Click(object sender, EventArgs e)
        {
            //Create an array of string objects
            String[] nums = new String[5];
            nums[0] = "1";
            nums[1] = "2";
            nums[2] = "3";
            nums[3] = "4";
            nums[4] = "5";
            //Add listbox elements to the listbox1
            listBox1.Items.AddRange(nums);
            double total = 0;
            //use foreach loop to find the total of the itesm in the listBox1
            foreach (String item in listBox1.Items)
            {
                total = total + int.Parse(item);
            }
            //Show the total value in result text box
            resultTxtBox.Text = total.ToString();
        }
    }
}


Step5:

Run the application :Output


Related Solutions

This is for a VF-30 Bonfiglioli worm drive Gearbox 6.1 Housing 6.2 Worm Gear 6.3 Worm...
This is for a VF-30 Bonfiglioli worm drive Gearbox 6.1 Housing 6.2 Worm Gear 6.3 Worm Shaft For each of the MAJOR components (6.1, 6.2 and 6.3) stated only, analyze and identify the manufacturing processes used to make the component – both primary (bulk shape forming) and secondary (or finishing) processes. Include sub-sub-section as follows for each component: o 6.1.1 Component Observations: Describe your observations of the physical component which indicate what manufacturing processes were performed. Include an annotated picture...
How would you find if numbers in an array element add up to a certain sum...
How would you find if numbers in an array element add up to a certain sum so for example if my array element consists of: INPUT: 200, 10, 50, 20 and my output asks if these elements add to: 210? YES (200+10) 260? YES (200+10+50) 30? NO What method would you suggest to look through the elements in an array (which im going to add through a text file) and determine if these sums exist in O(n^2)?
Please respond to the following problems from Chapter 6 found in section 6.6: Problem 6.1: In...
Please respond to the following problems from Chapter 6 found in section 6.6: Problem 6.1: In section 6.2.3, we made the comment “Perception is reality”. What is the impact of this statement in the valuation of a tangible versus intangible asset? Problem 6.5: What is goodwill and how is it different from other intangible assets? Check the Rubric
Do the following present value problems. You must set up all present value problems before calculation....
Do the following present value problems. You must set up all present value problems before calculation. Merely writing down the answer (even if it is correct) is an automatic zero. You must show your work. a. Suppose we have a four year fixed-payment loan with $1000 payments made at the end of each year. Given a market interest rate of 12 percent, how much was initially borrowed? b. Suppose you were considering purchasing a $5000 machine today that would generate...
The following problem is similar in format and nature to previous assignments and/ or practice problems....
The following problem is similar in format and nature to previous assignments and/ or practice problems. Answers should be submitted with all “work shown”. Provide a verbal explanation/description of your answers. Submissions graded on the basis of: content (arriving at the correct answers), fully explaining the reasoning/logic upon which the anwers are based, grammar & writing, and basic “quality of presentation”. See the top of Modules for examples of high quality presentation, writing, and general “upper-level university” submissions. PROBLEM: Assume...
Modify the code below to implement the program that will sum up 1000 numbers using 5...
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 sum up numbers from 801 - 1000 Make main thread wait for other threads to finish execution and sum up all the results. Display the total to the user. #include <pthread.h> #include <stdio.h> #include <stdlib.h> #define N_OF_THREADS 4 void * print(void...
You must use Excel for solving all the problems In problem 13.9 on page 501, an...
You must use Excel for solving all the problems In problem 13.9 on page 501, an agent for real estate company wanted to predict the monthly rent for one-bedroom apartments, based on the size of the apartment. The data are stored in rentsliverspring. Use the results of that problem. a. at the 0.05 level of significance, is there evidence of a linear relationship between the size of the apartment and the monthly rent? b. Construct at 95% confidence interval estimate...
For problems involving calculations you must show your work for credit. For each problem below, you...
For problems involving calculations you must show your work for credit. For each problem below, you may assume aqueous solutions at T = 25. °C. 1) For each of the cell diagrams below find the half-cell oxidation reaction, the half-cell reduction reaction, the net cell reaction, and the standard cell potential (E°cell). You may use the half-cell reduction potential table in the ppt presentation to find E°cell. a) Cd(s) | Cd2+(aq) || I-(aq) | I2(s) | Pt(s)   b) Pb(s) |...
You must include all EXCEL printouts and the 6 step write-up for both problems. The questions...
You must include all EXCEL printouts and the 6 step write-up for both problems. The questions are given below. USING ANOVA: Assuming variances are equal. Concerned about Friday absences, management examined the number of persons absent for each of the past three Fridays. Does this sample provide sufficient evidence to conclude there is a significant difference in the average number of absences? Use alpha = .05. Plant 1 Plant 2 Plant 3 Plant 4 19 17 27 22 24 20...
Problem 2: Indirect and Euclidean proofs (40 pts) For the following problems, you must use an...
Problem 2: Indirect and Euclidean proofs (40 pts) For the following problems, you must use an indirect proof technique. (a) (10 pts) Prove indirectly that, if a 2 is a multiple of 31, then so is a. Your proof should not consist of 30 cases – this includes absolutely no implied cases using horizontal dots (· · ·) and/or vertical dots (. . .). (b) (15 pts) Using the result of question (a), prove that √ 31 is not a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT