programming using visual studio

Sigchi4life
Category:
Programming
Price: $25 USD

Question description

Exercise :    Arrays

You must use one (or more) array(s) for each question.

Q. 1  Declare an array that can hold 25 decimals.  Fill (i.e., initialize) its first five elements with a loop using static values (e.g., array_name= 56.78).  Add all its elements using another loop.  Display the result (total) in a listbox. 

Using a “for each” loop, display all the elements in the listbox.  What do you notice?   NOTE:  As mentioned in the class, we have not been using first element.  You will notice that when you declare an array of 25 (e.g., Dim array_name(25) as…) you actually get 26 elements.  Remember that the first element is: array_name(0).  

Q.2  Declare an array that can hold 25 decimals.  Initialize its first three elements with a loop using inputboxes.  Multiply all these three elements using another regular “for” loop.  Display the result (of multiplication of the values you entered) in a listbox.  Make sure your result is non-zero.   HINTS:  (a) When an array element is not filled, it is 0 (b) When you multiply any number with a 0, you get a 0.  (c) Do not forget that you have 0th element to consider.

Q.3  Declare an array that can hold 10 strings.  Fill its first three elements with a regular “for” loop using inputboxes.  Then, using the “for each” loop, display all array elements in a listbox.

Q.4 Repeat Q.2:  This time, use the “for each” loop for total/multiplication.  HINTS for the multiplication result:  (a) “for each” loop takes ALL the element of an array.  (b) When an array element is not filled, it is 0 (c) When you multiply any number with a 0, you get a 0.  How do you avoid this problem?  See Q. 5.

Q. 5 Declare an array that can hold 20 decimals.  Fill its first three elements with a loop using inputboxes.  Fill the rest of the elements with all 1.  Multiply all its elements using a “for each” loop.  Display the result (of multiplication) in a listbox.  Make sure your result is non-zero.    

Q. 6 Fill all the elements of an array with a random number between 1 and 6.   Make sure that all the elements are filled with different random values.  You can choose (a) size of an array, (b) display control, etc.

Q. 7 Fill an array of size 27 with integers  (NOTE: I will not nitpick on 27 or 28 elements with/without the 0th element).  Display all its 5th element in the listbox (i.e, element number 5, 10, 15, etc.).  HINT:  “for” loop with STEP.

Q. 8 Add all the 5th element of an integer of size 27.

Q. 9 In Q. 6, add code so that:  If any of the element is 6, your program displays “bingo.” You can choose any display control, etc.

Q. 10 Add all the even elements of an integer array of size 10.


Q. 11 Your program displays an inputbox saying, “enter a number.” Then it displays another inputbox asking the user, “enter a larger number.”  Then, your program displays ten random numbers between that range and adds them.  You must use an array.

Pseudocode:   

Declare an array of size 10 or larger

            A = inputbox 1

            B =inputbox 2

            for loop

              C = a random # from A to B

              array_element = C

                keep adding C to another variable (say, TOTAL)

            Next


Tutor Answer

(Top Tutor) Daniel C.
(997)
School: UIUC
PREMIUM TUTOR
Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1824 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors