Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsDiscussion Forum → Q Basic Help
Q Basic Help
2008-02-11, 5:48 PM #1
Ok I have this huge Q Basic 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

Quote:
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....

Code:
'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
(JKLE_Cougar) from JK MP Community
discord.me/jediknightdarkforces2
2008-02-11, 5:51 PM #2
When is it due? A decade and a half ago?
Warhead[97]
2008-02-11, 5:53 PM #3
funny... seriously no more comments like this I really need help

and if you must know we start off on Q Basic then go up to C++ then Java thats just how my school does it
(JKLE_Cougar) from JK MP Community
discord.me/jediknightdarkforces2
2008-02-11, 8:52 PM #4
that's a pretty damn retarded way of doing it. QBasic doesn't make programmers, QBasic makes ****ty programmers.
2008-02-11, 9:02 PM #5
also, java last? what's the point. java is a means to an end, not an end.
2008-02-11, 9:09 PM #6
GOTO 1991 :downswords:

seriously though i am really sorry, i can't help you.
Warhead[97]
2008-02-11, 9:24 PM #7
You should consider transferring to a school that is actually interested in your development as a programmer instead of being interested in your ability to modify GORILLA.BAS.
2008-02-11, 9:41 PM #8
Im not going into programing... but I have to take programing classes and Java isnt the end it keeps going idk whats after that
(JKLE_Cougar) from JK MP Community
discord.me/jediknightdarkforces2
2008-02-11, 10:01 PM #9
Code:
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace MahProgram
{
    public class AirlineData
    {
        private string _sCity;
        private string _sAirline;
        private string _sPassenger;  //What the **** is this anyway? Passenger name or total passengers?

        public string City
        {
            get { return _sCity; }
            set { _sCity = value; }
        }

        public string Airline
        {
            get { return _sAirline; }
            set { _sAirline = value; }
        }

        public string Passenger
        {
            get { return _sPassenger; }
            set { _sPassenger = value; }
        }
    }

    public class TheProgram
    {
        private int _wPassengerCount;
        private AirlineData _ad;
        List<AirlineData> _lstAirline****;

        private const string FILE_PATH = @"c:\path\to\DATA1.DAT";

        private void LoadFile()
        {
            string sLine = string.Empty;
            string[] saStrings;
            AirlineData ad;
            using (TextReader tr = new StreamReader(FILE_PATH))
            {
                while ((sLine = tr.ReadLine()) != string.Empty)
                {
                    saStrings = sLine.Split('\t');  //Assuming tab delimited, specs never said otherwise.

                    if (saStrings.Count == 3)
                    {
                        ad = new AirlineData();
                        ad.City = saStrings[0];
                        ad.Airline = saStrings[1];
                        ad.Passenger = saStrings[2];

                        _lstAirline****.Insert(ad);
                    }
                }
            }
        }

        /// <summary>
        /// LINQ is ****ing badass.
        /// </summary>
        private void GenerateReport()
        {
            var vAirports = from air in _lstAirline****
                            group air by air.City;

            foreach (IGrouping<string, AirlineData> airData in vAirports)
            {
                Console.WriteLine("City {0}", airData.Key);
                foreach (var data in vAirports)
                    Console.WriteLine("\t {0} on {1}", data.Passenger, data.Airline);
            }
        }
    }
}

Ah **** I did it again. Oh well.
Code to the left of him, code to the right of him, code in front of him compil'd and thundered. Programm'd at with shot and $SHELL. Boldly he typed and well. Into the jaws of C. Into the mouth of PERL. Debug'd the 0x258.
2008-02-11, 10:29 PM #10
Originally posted by BobTheMasher:
When is it due? A decade and a half ago?


<3
If you choose not to decide, you still have made a choice.

Lassev: I guess there was something captivating in savagery, because I liked it.
2008-02-11, 10:46 PM #11
Originally posted by Jon`C:
You should consider transferring to a school that is actually interested in your development as a programmer instead of being interested in your ability to modify GORILLA.BAS.


Ah, the memories!

Seriously, though. This is like a Game Design class asking you to create a project in Dark Forces.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2008-02-11, 10:47 PM #12
Yes, it's just bizarre. You'll never ever be able to apply what you learn to anything else.
2008-02-11, 10:53 PM #13
Just curious, but what would you consider a good starting language Joncy?
2008-02-11, 10:54 PM #14
Originally posted by JediGandalf:
Code:
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace MahProgram
{
    public class AirlineData
    {
        private string _sCity;
        private string _sAirline;
        private string _sPassenger;  //What the **** is this anyway? Passenger name or total passengers?

        public string City
        {
            get { return _sCity; }
            set { _sCity = value; }
        }

        public string Airline
        {
            get { return _sAirline; }
            set { _sAirline = value; }
        }

        public string Passenger
        {
            get { return _sPassenger; }
            set { _sPassenger = value; }
        }
    }

    public class TheProgram
    {
        private int _wPassengerCount;
        private AirlineData _ad;
        List<AirlineData> _lstAirline****;

        private const string FILE_PATH = @"c:\path\to\DATA1.DAT";

        private void LoadFile()
        {
            string sLine = string.Empty;
            string[] saStrings;
            AirlineData ad;
            using (TextReader tr = new StreamReader(FILE_PATH))
            {
                while ((sLine = tr.ReadLine()) != string.Empty)
                {
                    saStrings = sLine.Split('\t');  //Assuming tab delimited, specs never said otherwise.

                    if (saStrings.Count == 3)
                    {
                        ad = new AirlineData();
                        ad.City = saStrings[0];
                        ad.Airline = saStrings[1];
                        ad.Passenger = saStrings[2];

                        _lstAirline****.Insert(ad);
                    }
                }
            }
        }

        /// <summary>
        /// LINQ is ****ing badass.
        /// </summary>
        private void GenerateReport()
        {
            var vAirports = from air in _lstAirline****
                            group air by air.City;

            foreach (IGrouping<string, AirlineData> airData in vAirports)
            {
                Console.WriteLine("City {0}", airData.Key);
                foreach (var data in vAirports)
                    Console.WriteLine("\t {0} on {1}", data.Passenger, data.Airline);
            }
        }
    }
}

Ah **** I did it again. Oh well.


class AirlineData makes me want to gouge my eyes out with a spoon.
"it is time to get a credit card to complete my financial independance" — Tibby, Aug. 2009
2008-02-11, 11:26 PM #15
Originally posted by Freelancer:
class AirlineData makes me want to gouge my eyes out with a spoon.


Are you kidding? Built-in property support is probably C#'s best feature after attributes.
2008-02-11, 11:54 PM #16
Originally posted by Cool Matty:
Just curious, but what would you consider a good starting language Joncy?


It depends entirely on what you are going to be doing with it.

C# is an excellent language for beginners (but moreso for professionals). Easy to learn, plenty of high-level abstractions and a standard library that uses human-readable names. It also provides higher-level OOP facilities that are simply not possible in other languages (such as delegates, security domains and marshalling).

Haskell isn't bad if you tend to think more in terms of algorithms and formulas, but it probably won't be as useful in the long run as an imperative language like C and C#.

C is the penultimate imperative language and it doesn't have any excessively complex abstractions. To learn C effectively, though, you need to learn about what your computer's hardware is doing. That can be a challenge.

I don't think it really matters what language you learn first as long as BASIC isn't one of them. BASIC's not a programming language, it's a shopping list. It's an impractical oversimplification that has nothing in common with any other higher-level language because higher-level languages tend to have things like stacks and scopes and functions and types and calling conventions and return values and exceptions.

You want to be really hardcore? Learn assembly. It's a list of errands like BASIC but at least it'll be easier to understand how your C code turns into Assembly when it's time to get real work done.
2008-02-11, 11:58 PM #17
http://www.javaworld.com/javaworld/jw-09-2003/jw-0905-toolbox.html
"it is time to get a credit card to complete my financial independance" — Tibby, Aug. 2009
2008-02-12, 12:03 AM #18
I think Q BASIC is a useful starting language -- if you have not yet advanced to junior high school.

Q BASIC got me thinking about manipulating algebraic variables when my public school's lessons were still trying to teach us long division.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2008-02-12, 12:15 AM #19


And? All you've told me is that you completely failed to read past the first paragraph of that article.
2008-02-12, 12:26 AM #20
allow me to elaborate,
Attachment: 18502/sigh_freelancer_read_articles_before_using_them_as_your_argument_without_commenting_for_yourself.png (15,557 bytes)
2008-02-12, 7:41 AM #21
Geez, as long as you're using BASIC you need to be using VB.NET... then you get the whole .NET framework plus object-oriented language construct that makes it fairly trivial to do what you want to do (as Gandalf illustrated. It wouldn't look too much different in VB.NET, in fact I have an automated C#<->VB.NET converter).

I don't even remember how to use QBASIC anymore. That's how useful my QBASIC experience has been. I do remember that QBASIC is a stripped-down version of the superior QuickBASIC. If you're going to use an obsolete language, at least use one with a debugger.

http://en.wikipedia.org/wiki/QuickBASIC

Jon`C QBASIC actually does have functions and return values. And scope (GLOBAL keyword, functions, etc). Doesn't it have types too? Not too sure about that though.

Also, class AirlineData is a very short and concise class, as far as classes go. Pretty much all of my classes are far bigger and more unwieldy. You will rarely find a real-world object with only three properties.

Jon`C... sometimes you need to do bounds checking or event triggering (or control invalidation) inside a property's set. Not needing get/set might make it simpler, but then you have a variable, not a property, and you lose that bounds checking and event triggering ability.

2008-02-12, 8:39 AM #22
C# 3.0 has automatic generation of get/set on properties, like so:

Code:
public string Name { get; private set; }

Which generates a public get and private set for the property.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2008-02-12, 9:16 AM #23
print (lol Qbasic...);
Was cheated out of lions by happydud
Was cheated out of marriage by sugarless
2008-02-12, 2:49 PM #24
SYNTAX ERROR

(You forgot single quotes. Oh, and QBASIC doesn't tell you where or what was wrong, just that something is.)
2008-02-12, 4:35 PM #25
Originally posted by The Mega-ZZTer:
Jon`C... sometimes you need to do bounds checking or event triggering (or control invalidation) inside a property's set. Not needing get/set might make it simpler, but then you have a variable, not a property, and you lose that bounds checking and event triggering ability.


when you say "Jon`C... s" do you actually mean "Freelancer... s" because I'm pretty sure you're preaching to the goddamn choir here.
2008-02-13, 12:42 AM #26
Originally posted by The Mega-ZZTer:
Also, class AirlineData is a very short and concise class, as far as classes go. Pretty much all of my classes are far bigger and more unwieldy. You will rarely find a real-world object with only three properties.


Someone needs to go back and review their OO Design Principles.
2008-02-13, 12:44 AM #27


I read this a while back. NONE of it applies to C#. Or, where you could twist what it's saying and apply it to C#, the guy doesn't understand what he's arguing against.

↑ Up to the top!