Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: QBasic Help!  (Read 3364 times)

0 Members and 1 Guest are viewing this topic.

wii0515

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    QBasic Help!
    « on: September 28, 2010, 06:09:14 PM »
    I needed help with a question for my class, QBasic Programming. This is the question.

    If you have the book its on page 118 number 4

    4. Write a program to list several activities and the number of calories expended during 15, 30, and 60 minutes of each activity. Use the following Data:

    Activity             Calories Burned per Minute
    Sleeping           2.3
    Jogging            15.0
    Sitting              1.7

    Use READ and DATA statements to place the data in variables. Then use commas to space the output so that is looks similar to the following:

    Activity          15 Minutes     30 Minutes     60 Minutes
    Sleeping         xxx.xx            xxx.xx            xxx.xx
    Jogging          xxx.xx            xxx.xx            xxx.xx
    Sitting            xxx.xx            xxx.xx            xxx.xx

    ghostdog74



      Specialist

      Thanked: 27
      Re: QBasic Help!
      « Reply #1 on: September 28, 2010, 07:26:40 PM »
      wow, didn't know anyone would still want to learn QBasic.  I hope its a free class you are taking, if not, its certainly not worth the school fees you are paying for.

      wii0515

        Topic Starter


        Newbie

        • Experience: Beginner
        • OS: Unknown
        Re: QBasic Help!
        « Reply #2 on: September 28, 2010, 07:37:21 PM »
        well this class i am taking is free and it is just a beginning to comp prog

        ghostdog74



          Specialist

          Thanked: 27
          Re: QBasic Help!
          « Reply #3 on: September 28, 2010, 08:12:50 PM »
          Qbasic is out of date. Try using a better programming language (eg Python), where you can learn about advance data structures like arrays/hashes/collections and much more.

          Code: [Select]
          print "%-15s%-15s%-15s%-15s" %("Activity","15 min","30 min","60 min")
          f=open("file")
          f.readline() # get first line
          for line in f:
             act, t=line.rstrip().split()
             print "%-15s%-15s%-15s%-15s" %( act,float(t)*15,float(t)*30,float(t)*60 )
          f.close()

          output

          Code: [Select]
          C:\test>python test.py
          Activity       15 min         30 min         60 min
          Sleeping       34.5           69.0           138.0
          Jogging        225.0          450.0          900.0
          Sitting        25.5           51.0           102.0


          If you insist on something from M$, try learning vbscript instead.

          OPRESION



            Newbie

            • Experience: Beginner
            • OS: Unknown
            WELCOME!
            « Reply #4 on: September 28, 2010, 10:33:11 PM »