English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am having problem doing this programing assignment. I am a accounting student, but I'm taking this programing class for elective. I never program before, so can anyone help me start or give me some advise as how to do this? Thanks!!! I know how to do the form, just the coding part I need help.

I need to create a windows application which can input an indefinite number of first names and ages into an array, sort the array by first name, and display the list of names and ages in ascending order.
The additional requirements are:
1. You must use a Pre-test ‘Until’ loop, a post-test ‘While’ loop, and a ‘For’ loop to perform the operations of sorting and displaying the array.
2.You must use an instance of a custom Structure to hold the first names and numbers in the array. The structure must have fields or properties of at least two different data types.
3.You must sort the array using the ‘bubble sort’ method.

2007-02-23 05:50:31 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

3 answers

1.) This question has a lot you may get some better results by breaking ito down into simpler tasks
2.) I recommend that you activate your E-mail in your account. I & others maybe able to give you more detailed info and files if necessary

Answers:

Your data( a.k.a. Record) for each individual is FirstName & Age. It is possible that you will have duplicate names like John or Bob entered.

You can enter record data (Name, Age) into a single Multiple Element Array or several Single element arrays. Multi Element arrays use several index values myArray(index1, index2) index2 would only be of the vaules 0 & 1 where 0 would be used for the name and 1 would be used for the Age. Index1 would be used with a counter and would provide a unique number for each record entered.

so:
myArray(1,0) = 'Bob'
myArray(1,1) = 23

Single element arrays have only one index element but you need several arrays (2 in this case) to hold your data fields . Each array will share the same index value for each record added.

So the first part of your program will be to load user input into the arrays and then print it back. This is unsorted data both input and output but is a first step you will need to accomplish in order to create the rest of the program.

I would recommend using three single element arrays:

arrayName(index) string
arrayAge(index) integer
arrayIndex(index) integer

The index array will store index values which will be used to read the other two arrays. Later when sorting your data you can rearrange the list of index values in the array so as to print out the randomly entered data in a sorted fashon.

But for now you can just use the arrayName and arrayAge arrays


EDIT:
I tried to respond to your email by Yahoo mailer returns it as an undeliverable E-mail. I seem to have a Yahoo mailer issue sending mail. anyway here is my response to your email.

following single element arrays arrays use the same index value to relate the individual data fields to a record. In other words the index value identifies a specific record entered. Each record will be comprised of a name and an age, I preface the array name with ay to indicate to me that it is an array.

DIM ayName() as string
DIM ayAge as integer
DIM ayIndex as integer


redim ayName(100)
redim ayAge(100)
redim ayIndex(100)

The above declares the arrays as specific data types and then dimensions the array sizes so as to hold upto 101 records. The array index values start at zero so 0 to 100 gives you 101 seperate records.

assume that I have entered several records via input boxes , so the contents of these arrays will be

ayName(0) = 'Mark' ayAge(0) = 22 ayIndex(0) = 0
ayName(1) = 'Tom' ayAge(1) = 30 ayIndex(1) = 1
ayName(2) = 'Bill' ayAge(2) = 40 ayIndex(2) = 2

The index array is used to present the data from the other arrays. By sequencing through the ayIndex array you get the index value to use in the other two arrays to get the data

So with the above index array values you will print out the entered data stored in ayName and ayAge in the order they were entered into the PC.

By sorting the Name array the index array values can be reorded so as to printout the data in a different order (i.e. sorted by Name)

ayIndex(0) = 2
ayIndex(1) = 0
ayIndex(2) = 1


This is the concept of using an index array to extract data from other arrays in different orders.

Like I said in the answer the first step in your program is to ask for and record data into an array. Worrya about the actual sorting later. This should be enough to give you an idea on how to store the data so it can be recalled in any order via the index array.

2007-02-23 07:14:32 · answer #1 · answered by MarkG 7 · 0 0

Bubble Sort sucks, use the QuickSort and the teacher will give you an A, guaranteed!

Seriously, have you gone to class? You can't just learn this stuff in a few hours, and since we can't help you much too much over Yahoo Answers, I really don't know what to tell you.

You could head over to http://www.experts-exchange.com and post a question, just tell em it's homework and they'll hook you up.

2007-02-23 05:55:19 · answer #2 · answered by Anonymous · 1 1

I would suggest you obtain a copy of Visual Basic for Dummies (no offense), it's an excellent guide for a beginner.

2007-02-23 05:54:59 · answer #3 · answered by Anonymous · 1 0

fedest.com, questions and answers