QBasic Hard! Need help please.

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
StealthTools
Newbie
Posts: 2
Joined: Sat Apr 26, 2008 11:24 am

QBasic Hard! Need help please.

Post by StealthTools »

TASK

Create a flowchart for a program that allows the user to enter the name, ship, and prison cell number for prisoners in the Klingon prison colony. The data should be stored in three parallel arrays, and the arrays should be alphabetized by prisoner name. The user should be able to display information about a particular prisoner when his or her name is entered.

Use QBasic to write a program that allows the user to enter the name, ship, and prison cell number for prisoners in the Klingon prison colony. The data should be stored in three parallel arrays, and the arrays should be alphabetized by prisoner name. The user should be able to display information about a particular prisoner when his or her name is entered.
Your program should include the following:

?Correct use of three parallel arrays
?Use of binary search to locate prisoners by name
?Correct, formatted output


I am not kidding this is what it really says, lol

The Klingons have captured Spock, science officer of the U.S.S. Enterprise. Captain Kirk has broken into their prison colony to free him. He has reached the computer that possesses information concerning all of the prisoners, including their cell numbers. Write a program to prompt the user to enter the following data into the program. The data should be stored in all three parallel arrays:

Prisoner Ship Cell#
Kanobi Falcon 328
Spock Enterprise 562
Yoda None 122
Mudd Pleasure Dome 222
Khan Botany Bay 009
Jetson Astrofly 468
Rogers Galaxy 2 727
Koeing Alpher 999
Adama Galactic 987
Who Tardis 585

Alphabetize the data by name, and display information regarding a prisoner when his or her name is entered. Use a binary search routine in your program to speed Captain Kirk's search for Spock.



Hey.. That is the homework I have to do... I am stressed out because I have high-school work to do over this.. I will get back to this post later today.. I will need help on this program I believe.. or at least someone yo walk me through it.. I don't know how to code an array or nothing, lol ... at lunch at school right now.. I know some of you guys are just itching for a problem to work on, lol.. I was like that but It turned out a change of lifestyle can throw you off balance.

I am only taking QBasic because it was a requirement for taking Visual Basic.... and guess what... Where I live now... it ISN'T!!! now I am taking 2 college classes and 4 high-school classes.. help meh please, lol

When I do post the code I will probably need someone to walk me through some of it..

Thanks for your help


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

Here is what I have so far in regards to the program I have to create...

I am wondering if when Name$ or the name of the prisoner is sorted alphabetically if it will switch the names around leaving the
cell numbers and ship names behind making them be with another prisoners name.

I am also wondering on how to make a freakin binary seach for this program, lol

Hope what I have works.. probably doesn't..

Help Meh Pl0x!

Code: Select all


'*** This program displays information reguarding ***
'*** A prisoner when his or her name is entered. ***


'*** This procedure prompts the user to enter the name ***
'*** of the prisoner, the ane of the prisoner's ship ***
'*** and the prisoners cell number. ***

CLS

DIM Nam$(1 TO 10), Ship$(1 TO 10), Cell(1 TO 10)

FOR Count = 1 TO 10
INPUT " Enter the name of the prisoner:", Nam$(Count)
PRINT
INPUT " Enter the name of the prisoner's ship:", Ship$(Count)
PRINT
INPUT " Enter the cell number where the prisoner is held:", Cell(Count)
PRINT
NEXT Count

CLS


'*** This procedure uses the bubble sort to alphabetically sort the array Nam$ ***

Final = 9
Flag = 1

'*** Execute loop until no exchanges are made ***

DO WHILE Flag = 1
Flag = 0
FOR Count = 1 TO Final
'*** If names are out of order, switch them ***
IF Nam$(Count) > Nam$(Count+1) THEN
SWAP Nam$(Count), Nam$(Count+1)
Flag = 1 '*** Reset Flag, indicating a switch
END IF
NEXT Count
Final = Final - 1
LOOP


'*** This procedure prompts the user to enter the name of a prisoner ***
'*** and displays information about that prisoner ***

PRINT
PRINT
INPUT "Enter the name of the prisoner you wish to view information about:",
PRINT
PRINT


Thanks for any help anyone may be able to provide.
roy
Veteran
Posts: 55
Joined: Sun Jul 29, 2007 2:39 pm
Location: London

Post by roy »

You have already posted this on another forum and you have still not altered your SWAP routine.
User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat »

I think you need two more swap routines for the other arrays.

And then, once you're sorted, start in the middle of the list. If your target is less than your observed, go to the lower end, else go higher. Then take that new list (from the extreme to your previous number), and repeat until you hit your target. Binary search (either up or down until target)

Here's what I'm talking about:

Get Input (9,2,4,7,3,6,0)

Sort (0,2,3,4,6,7,9)

What are you looking for (let's say 2)

Start in the middle (0,2,3,4,6,7,9)

Since 2 (your number) is less than 4, go down to the middle of (0,2,3)

Which is the target.

Dual enrollment?
For any grievances posted above, I blame whoever is in charge . . .
StealthTools
Newbie
Posts: 2
Joined: Sat Apr 26, 2008 11:24 am

Alternate Post

Post by StealthTools »

I posted on the other forum because I thought that it was another website altogether?

That other website..roy...helped me alot. I will alter my code and try to understand what people have told me tomorrow afternon when I am at my computer.

Thanks,

StealthTools

Reply: Yes, I am inrolled in dual enrollment
Post Reply