Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,390 Programmers. There are 1,359 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

QBasic.. hard...

 
Reply to this topicStart new topic

QBasic.. hard..., Binary search, bubble sort...

StealthTools
post 25 Apr, 2008 - 06:18 AM
Post #1


New D.I.C Head

*
Joined: 11 Mar, 2008
Posts: 31



Chapter 9: Arrays and Searching and Sorting

Level 2, Problem 3
Due Date: Tuesday, April 29, 2008

Level 2, Problem 3 (Klingon Prisoners)

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.

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

CODE

'*** 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.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 04:54AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month