Qbasicnews.com
December 06, 2019, 03:17:54 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: need help with qbasic print areas  (Read 6184 times)
qbasicnewbie
New Member

Posts: 1


« on: March 08, 2009, 05:18:45 PM »

could someone please walk me through how to make a table using qbasic please add me on msn rs2maniak500@hotmail.com or post here

heres what i have i just cant figure out how to put the output section into a table

REM *****calculating area and perimeter of squares*****
REM David Rosenberg
REM 3/5/09
COLOR 25,7
CLS

REM INPUT

LET sport1$ = football
LET length1 = 360
LET width1 = 190

LET sport2$ = baseball
LET length2 = 94
LET width 2 = 50



REM PROCESSING
LET perimeter1$ = 2*length1+2*width1
LET area$ = length1*width1
LET perimeter2$ = 2*length2+2*width2
LET area2$ = length2*width2




REM OUTPUT

PRINT "The length (feet) of a football field is: " length1
PRINT "The width (feet) of a football field is: "; width1
PRINT "The perimeter (feet) of a football field is: " perimeter1
PRINT "The area (square feet) of a football field is: ";area1
PRINT
PRINT "The length (feet) of a basketball court is "; length2
PRINT "The width (feet) of a basketball court is: "; width2
PRINT "The perimeter (feet) of a basketball court is: "; perimeter2
PRINT "The area (square feet) of a basketball court is: "; area2



END
« Last Edit: March 08, 2009, 05:22:03 PM by qbasicnewbie » Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #1 on: March 08, 2009, 09:09:44 PM »

could someone please walk me through how to make a table using qbasic please add me on msn rs2maniak500@hotmail.com or post here

heres what i have i just cant figure out how to put the output section into a table

REM *****calculating area and perimeter of squares*****
REM David Rosenberg
REM 3/5/09
COLOR 25,7
CLS

REM INPUT

LET sport1$ = football
LET length1 = 360
LET width1 = 190

LET sport2$ = baseball
LET length2 = 94
LET width 2 = 50

REM PROCESSING
LET perimeter1$ = 2*length1+2*width1
LET area$ = length1*width1
LET perimeter2$ = 2*length2+2*width2
LET area2$ = length2*width2

REM OUTPUT

PRINT "The length (feet) of a football field is: " length1
PRINT "The width (feet) of a football field is: "; width1
PRINT "The perimeter (feet) of a football field is: " perimeter1
PRINT "The area (square feet) of a football field is: ";area1
PRINT
PRINT "The length (feet) of a basketball court is "; length2
PRINT "The width (feet) of a basketball court is: "; width2
PRINT "The perimeter (feet) of a basketball court is: "; perimeter2
PRINT "The area (square feet) of a basketball court is: "; area2

END
Hi David, here's a few comments.

1) You don't need to use LET anymore, although it will work.  LET was used on very old versions of Basic.

2) Your variables SPORT1$ and SPORT2$ are never used. Delete these lines.

3) Your variables PERIMITER1$, AREA1$, PERIMITER2$ and AREA2$ shoulld be numeric vaiables not string variables. You later refer to them as numeric varriables, which is correct.

4) You mention wanting to create a table. Why would you need a table?

5)  If you fix the variables, your program will work fine as is.

Regards..... Moneo

Logged
Clippy
Member
*
Posts: 84



« Reply #2 on: March 09, 2009, 02:50:13 PM »

Variable types:

STRING = $
INTEGER (whole numbers) = %
LONG (large integers) = &
SINGLE (decimal point numbers) = !
DOUBLE (large decimal point numbers) = #

Use the above variable suffixes or DIM AS the type needed.

DIM age AS INTEGER

Ted
Logged

Ralph
Ancient Guru
****
Posts: 544


« Reply #3 on: March 11, 2009, 07:47:21 PM »

One more thing:  You used
LET area$ = length1*width1
Following your method, it should have been:
LET area1$ = length1*width1

But, since even that is wrong, because, as Moneo has already pointed out, you're mixing a string (area1$) with numbers (length1 and width1).  Correctly, you should have:
LET area1 = length1*width1
and, gettting with the times, it should be:
area1 - length1*width1


Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!