Jump to content

Home

Anyone know Q Basic? I need help...


JKLE_Cougar

Recommended Posts

Ok I have this huge Q Basic program that I have to write and I am having a very difficult time writing it and i could really use some help.... Ive been staring at it for a while and its giving me a headache

 

Instructions:

The Federal Aviation Administration would like you to develop a program to report the number of passengers who fly out of a variety of airports.

 

Begin the project by asking the user whether the application is the one desired. This will give the user the option of exiting the program if it were run by mistake. Edit the answer for a case insensitive yes/no response, and only prepare the data file when the user responds ‘YES’.

 

Include in the project, a module which interactively builds an input file with the data listed below. Name the input file DATA1.DAT

 

Edit the airline field to insure that it contains only one of the following airline codes:

USA for USAir

AAL for American Airlines

DAL for Delta Airlines

 

Edit the Passenger load field to insure that no flight carries over 300 passengers.

 

The project should then contain a module to prepare a control break report passed upon the city to summarize and report passenger usage. Use the DATA1.DAT file as input for this module.

 

Input:

The input data below consists of airline flights containing the departure city, the airline used and the number of passengers on the specific flight. Enter the data below when building DATA1.DAT. The input records have already been sorted in ascending sequence by city to assist you in the development of your program.

 

List of City, Airline, and Passenger………

 

Output:

The output from the project is the airport usage report. The report is a control break report based upon the city. The report contains the city, the airline, and the number of passengers.

 

Intermediate totals should be printed for each city showing the total flights for each airline that services the city. The total number of passengers fro the city should also be printed.

 

At the end of the report, print the total passengers for all airports, the number of airports processed and the average number of passengers per airport. The report should be group indicated by city.

 

A sample of the report is shown below……..

 

Those are the instructions... heres what I got so far....

 

'Program 2
'Andrew L
'1-30-08
'
'
'Variable Dictionary
'Variable           What it means
'x$                 Decision yes or no
'tc                 Total Cities
'firstrecord        First Record
'fnum               Passenger number
'an$                Another Record?
'tc                 Total Counter
'sub1               Subtotal 1
'sub2               Subtotal 2
'a
'c
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'
'

CLS
PRINT "This is the Federal Aviation Administration Program... Do you want to run this program?"
INPUT x$
LET x$ = UCASE$(x$)
DO UNTIL x$ = "YES" OR x$ = "NO" OR x$ = "Y" OR x$ = "N"
 PRINT "Error"
 PRINT "Please Type Yes (Y) or No (N)"
 INPUT x$
 LET x$ = UCASE$(x$)
LOOP
DO UNTIL x$ = "NO" OR x$ = "N"
 GOSUB setup
 PRINT "Would you like to build a file?"
 INPUT x$
 LET x$ = UCASE$(x$)
   DO UNTIL x$ = "YES" OR x$ = "NO" OR x$ = "Y" OR x$ = "N"
     PRINT "Error"
     PRINT "Please Type Yes (Y) or No (N)"
     INPUT x$
     LET x$ = UCASE$(x$)
   LOOP
 DO UNTIL x$ = "NO" OR x$ = "N"
   GOSUB build
 LOOP
 GOSUB hdg
 GOSUB report
 'GOSUB total
LOOP
END

setup:
LET firstrecord = 1
LET tc = 1
LET pnum = 300
RETURN

build:
OPEN "f:\data.dat" FOR OUTPUT AS #1
 DO UNTIL an$ = "NO" OR an$ = "N"
   PRINT "Please Enter a City"
   INPUT c$
   PRINT "Please Enter the Airline"
   INPUT a$
   LET a$ = UCASE$(a$)
      DO UNTIL a$ = "USA" OR a$ = "AAL" OR a$ = "DAL"
         PRINT "Error"
         PRINT "Please enter USA or AAL or DAL"
         INPUT a$
         LET a$ = UCASE$(a$)
      LOOP
   PRINT "Please Enter the ammount of Passengers"
   INPUT p
      DO UNTIL p <= pnum
         PRINT "Error"
         PRINT "Please enter a number below "; pnum
         INPUT p
      LOOP
      WRITE #1, c$, a$, p
   PRINT "Would you like to write another record?"
   INPUT an$
   LET an$ = UCASE$(an$)
     DO UNTIL an$ = "YES" OR an$ = "Y" OR an$ = "NO" OR an$ = "N"
       PRINT "Error"
       PRINT "Please enter Yes (Y) or No (N)"
       INPUT an$
       LET an$ = UCASE$(an$)
     LOOP
 LOOP
CLOSE
RETURN

hdg:
PRINT
PRINT TAB(30); "AIRLINE USAGE REPORT"
PRINT
PRINT
PRINT TAB(1); "City"; TAB(34); "Airline"; TAB(67); "Passenger Load"
RETURN

report:
OPEN "F:\data.dat" FOR INPUT AS #1
DO UNTIL EOF(1)
 INPUT #1, c$, a$, p
 IF firstrecord = 1 THEN
   LET comp$ = c$
   LET firstrecord = 0
 END IF
 IF com$ <> c$ THEN
   PRINT sub1
   LET com$ = c$
   PRINT sub2
   LET c = 0
   LET a = 0
   LET tc = tc + 1
 END IF
GOSUB process
PRINT sub1
PRINT sub2
CLOSE
LOOP

process:
IF a$ = "AAL" THEN
 AAL = AAL + 1
 a$ = "American Air Lines"
END IF
IF a$ = "USA" THEN
 USA = USA + 1
 a$ = "U.S. Air Lines"
 ELSE
 DAL = DAL + 1
 a$ = "Delta Air Lines"
END IF


RETURN

 

Its giving me a headache looking at this and I could really use some guidance on the module I'm on right now.... I have a good amount of the Flow Charts and hierarchy chart done already its just these last 2 modules that I'm lost in...

Link to comment
Share on other sites

hey JKLE, if youre willing to give it a little while longer, someone around here may be able to help :) The clever coder types pop in a bit less frequently :)

 

In the interim, im sure you could find a more specific help forum for this stuff ?

 

good luck... Im a hardware guy so can be of no help at all Im afraid :(

 

mtfbwya

Link to comment
Share on other sites

Hope you didn't GOSUB everything because they give me headaches too. SUBs and FUNCTIONs are your friends.

 

I have to support a production application that uses QBASIC on DOS and your thread made me dust off my old books. I was working on it actually during my lunches, creating menus, error trapping, etc. Glad you got it working though. :)

Link to comment
Share on other sites

Hope you didn't GOSUB everything because they give me headaches too. SUBs and FUNCTIONs are your friends.

 

I have to support a production application that uses QBASIC on DOS and your thread made me dust off my old books. I was working on it actually during my lunches, creating menus, error trapping, etc. Glad you got it working though. :)

 

no yea I know what your saying, my professor said he wanted 6 gosubs or moduals, there was a problem with a if statement and i forgot to close a mod as well :lol:

 

all stupid things that threw off the entire program

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...