Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Visual Basic 2022 Construct a Sorter that can display 8 numbers in a list box which are input through the display. The list array is

Visual Basic 2022

Construct a Sorter that can display 8 numbers in a list box which are input through the display. The list array is constructed to handle up to 15 numbers. The person enters the numbers one at a time in the display and clicks ENTER to add the number to the end of the list. If the person wants to sort the numbers, the SORT key must be clicked. If the person wants to sum the current numbers in the list, the SUM key is clicked. If the person enters more than 15 numbers, an error message is displayed.

Clear Display Clears only the number just entered in the display.

Clear All Clears all values in the array and is ready to start a new list to sort.

Enter Moves the number from the DISPLAY to the List.

Sort Sorts the Current List.

Sum Sums the values in the Current List.

Sorting Use DO LOOPs or FORs to sort the numbers, NOT a Property or Function.

Display

Clear Display

Clear ALL

Enter

Sort

Sum

3

4

9

List of Numbers

(Sorted when Sort

Key clicked)

SUM

16

Sorting Numbers

Sorting 5 Numbers

Create an array to store the list of 5 numbers, call it ALIST.

Enter your numbers into the ALIST.

The ALIST may not use all 5 locations, therefore you must keep track of the number of entries.

Sort (in Ascending Order) using the following steps:Compare the first two entries: ALIST (1) and ALIST (2).

If ALIST(1) <= ALIST(2), no change in list. Go to (b).

If ALIST(1) > ALIST(2). Swap values using SWAP below.

Compare ALIST (1) and ALIST (3).

If ALIST(1) <= ALIST(3), no change in list. Go to (c).

If ALIST(1) > ALIST(3). Swap values using SWAP below.

Continue comparing ALIST(1) to all the values in ALIST.

When you finish comparing ALIST(1) to all values (swapping if the number is smaller), then ALIST(1) contains the smallest value in the list.

Repeat the above sequence for ALIST (2), steps a, b, and c.

Repeat the above process for ALIST(3), etc. for all values in ALIST.

SWAP: Remember that when you code A=B , that the value of B is written in A destroying what was in A.

Since the value of A is lost when written over,

you must store it somewhere, say TEMP.

Move ALIST(1) to TEMP. TEMP=ALIST(1)

Move smaller value to ALIST(1). ALIST(1)=ALIST(2)

Move the larger value to ALIST(2). ALIST(2)=TEMP

Use two loops with the ALIST subscripts changing to sequentially sort the numbers.

5. a

Values in the ALIST TEMP

5

6

6

6

ALIST(1)

5. c.

5. b.

5

ALIST(2)

8

ALIST(3)

3

ALIST(4)

4

ALIST(5)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions