1.

Solve : QBasic Help!?

Answer»

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.xxwow, 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.well this class i am taking is free and it is just a beginning to comp progQbasic 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. www.network54.com/forum/648955/



Discussion

No Comment Found