Geometry: Computer Fun

On this page we've put together a small collection of QBasic programs that help you solve some of the more common problems geometry deals with, such as finding the measure of the third angle of a triangle when you know the other two angles' measures.  Have fun!

Note that although the code is included on this page, there are links you can click on that will allow you to download the files in .BAS (QBasic v1.1) format.  If any problems arise, feel free to E-Mail John at jpp22@email.byu.edu.  Also, feel free to edit these programs and do whatever you want with them (they are public domain)!

For those using Microsoft® operating systems (MS-DOS, Windows, etc.), you can download the "official" QBasic (v1.1) from the following address: http://www.microsoft.com/windows/download/olddos.exe.  (It is included in an archive of old MS-DOS utilities.)

For those using other operating systems, there are many "unofficial" compilers available.  Search the Internet and you'll find a number of them.

Finding the third angle of a triangle
Classifying angles
Finding an exterior angle of a triangle
Angles of a polygon
Lengths of sides of right triangles
Lines
Volume and total area of a cylinder
Quiz on QBasic geometry programs


Finding the Third Angle of a Triangle

This program asks the user for the measures (in degrees) of two angles of a triangle and then figures out the measure of the third angle.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1997.
            ' Some source taken from Harper & Row
            ' Geometry by Max A. Sobel, pub. Scribner
            ' Laidlaw, NY.

            CLS                           ' Clears the screen.
10 PRINT "First angle"; 20 PRINT INPUT A 30 IF A > 180 THEN 10 40 PRINT "Second angle"; 50 INPUT B 60 IF (A + B) > 180 THEN 40 70 LET C = 180 - (A + B) 80 PRINT "Third angle = "; C END ' End of program.
Download the program.

Back to top.


Classifying Angles

This program takes the measure of an angle between 0° and 180° and classifies the angle as acute, right, or obtuse.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1997.
            '
            ' Some source taken from Harper & Row
            ' Geometry by Max A Sobel, pub. Scribner
            ' Laidlaw, NY.

            Start:
            CLS

            INPUT "Degrees in angle"; D
            IF D <= 0 THEN GOTO Start
            IF D >= 180 THEN GOTO Start
            IF D < 90 THEN GOTO Acute
            IF D = 90 THEN GOTO Right

            PRINT D; " is an Obtuse Angle.": GOTO 100

            Right:
            PRINT D; " is a Right Angle.": GOTO 100

            Acute:
            PRINT D; " is an Acute Angle.": GOTO 100

            100:
            INPUT "Another (Y/N)"; YN$
            IF YN$ = "y" THEN GOTO Start
            IF YN$ = "Y" THEN GOTO Start
            IF YN$ = "n" THEN GOTO Ending
            IF YN$ = "N" THEN GOTO Ending

            Ending:
            END ' End of program.
         
Download the program.

Back to top.


Exterior Angle of a Triangle

This program displays the measure of an exterior angle of a triangle, given the measures of the two remote interior angles.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1997.
            '
            ' Some source taken from Harper & Row
            ' Geometry by Max A. Sobel, pub. Scribner
            ' Laidlaw, NY.

            10 CLS
            20 INPUT "Measure of Angle A"; A
            30 IF A <= 0 THEN 10
            40 IF A >= 180 THEN 10
            50 INPUT "Measure of Angle B"; B
            60 IF B <= 0 THEN 50
            70 IF B >= 180 THEN 50
            80 LET E = (A + B)
            90 PRINT "Exterior angle = "; E
            100 INPUT "Another (Y/N)"; YN$
            110 IF YN$ = "Y" THEN GOTO 10
            120 IF YN$ = "y" THEN GOTO 10
            130 IF YN$ = "N" THEN GOTO 150
            140 IF YN$ = "n" THEN GOTO 150
            150 END
         
Download the program.

Back to top.


Sum of Measures of Angles of a Polygon

This program asks you how many sides an n-gon has and then displays the number of sides and the angle sum for all polygons from a three sided polygon (triangle) to the n-sided one you entered.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1997.
            '
            ' Some source taken from Harper & Row
            ' Geometry by Max A. Sobel, pub. Scribner
            ' Laidlaw, NY.

            10 CLS

            11 INPUT "How many sides does the polygon have"; I
            12 IF I < 3 THEN BEEP: GOTO 11
            13 LET Z = INT(I)

            20 PRINT
            30 PRINT "No. Sides", "Angle Sum"
            40 PRINT "---------", "---------"
            50 FOR N = 3 TO Z
            60 LET S = 180 * (N - 2)
            70 PRINT N, S
            80 NEXT N
            90 PRINT
            100 INPUT "Another (Y/N)"; YN$
            110 IF YN$ = "Y" THEN GOTO 10
            120 IF YN$ = "y" THEN GOTO 10
            130 IF YN$ = "N" THEN GOTO 150
            140 IF YN$ = "n" THEN GOTO 150 ELSE BEEP: GOTO 100
            150 END
         
Download the program.

Back to top.


Finding Lenghts of Sides of a Right Triangle

This program finds an unknown length of a sie of a right triangle.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1997.
            '
            ' Some source taken from Harper & Row
            ' Geometry by Max A. Sobel, pub. Scribner
            ' Laidlaw, NY.

            10 CLS
            20 PRINT "Enter lengths of sides"
            30 PRINT "of right triangle, legs"
            40 PRINT "first.  Enter a zero for"
            50 PRINT "the unknown side."
            55 PRINT
            60 INPUT "What is the length of Leg 1"; A
            70 INPUT "What is the length of Leg 2"; B
            80 INPUT "What is the length of the hypotenuse"; C
            90 If A < 0 THEN BEEP: GOTO 60
            100 IF B < 0 THEN BEEP: GOTO 70
            110 IF C < 0 THEN BEEP: GOTO 80
            120 IF A = 0 THEN GOTO 200
            130 IF B = 0 THEN GOTO 170
            140 LET C = SQR(A * A + B * B)
            150 PRINT "Hypotenuse = "; C
            160 GOTO 220
            170 LET B = SQR(C * C - A * A)
            180 PRINT "Unknown leg = "; B
            190 GOTO 220
            200 LET A = SQR(C * C - B * B)
            210 PRINT "Unknown leg = "; A
            220 INPUT "Another (Y/N)"; YN$
            230 IF YN$ = "Y" THEN GOTO 10
            240 IF YN$ = "y" THEN GOTO 10
            250 IF YN$ = "N" THEN GOTO 270
            260 IF YN$ = "n" THEN GOTO 270
            270 END
         
Download the program.

Back to top.


Coordinate Geometry: Lines

This program asks you for the endpoints of a line segment that has been graphed on a coordinate plane.  It then computes the slope of the segment, the midpoint of the segment, and the distance between the endpoints.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1998.
            '
            ' Some source taken from Harper & Row
            ' Geometry by Max A. Sobel, pub. Scribner
            ' Laidlaw, NY.

            5 CLS
            10 PRINT "Input coordinates of Point 1."
            15 INPUT "X1 = "; X1
            20 INPUT "Y1 = "; Y1
            30 PRINT "Input coordinates of Point 2."
            35 INPUT "X2 = "; X2
            40 INPUT "Y2 = "; Y2
            50 LET M1 = ((X1 + X2) / 2)
            60 LET M2 = ((Y1 + Y2) / 2)
            70 PRINT "Midpoint = ("; M1; ", "; M2; ")"
            80 LET D = SQR(((X2 - X1) ^ 2) + (Y2 - Y1) ^ 2)
            90 PRINT "Distance = "; D
            100 IF X1 = X2 THEN 140
            110 LET M = ((Y2 - Y1) / (X2 - X1))
            120 PRINT "Slope = "; M
            130 GOTO 150
            140 PRINT "Slope is undefined."
            150 INPUT "Another (Y/N)"; YN$
            160 IF YN$ = "Y" THEN GOTO 5
            170 IF YN$ = "y" THEN GOTO 5
            180 IF YN$ = "N" THEN GOTO 200
            190 IF YN$ = "n" THEN GOTO 200 ELSE BEEP: GOTO 150
            200 END
         
Download the program.

Back to top.


Volume and Total Area of a Cyliner

This program computes the volume or total area of a cylinder.
            ' Programmed by John Paul Pruess.
            ' Completed on July 18th, 1997.

            Start:
            CLS
            LET P = 3.14159

            PRINT "1. Volume"
            PRINT "2. Total Area"
            PRINT
            INPUT "What is your selection"; S
            LET S2 = INT(S)
            IF S2 < 1 THEN BEEP: GOTO Start
            IF S2 > 2 THEN BEEP: GOTO Start
            IF S2 = 2 THEN GOTO TotalArea
            IF S2 = 1 THEN GOTO Volume

            Volume:
            CLS
            INPUT "How long is the radius"; R
            INPUT "How tall is the cylinder"; H
            LET V = (P * H * (R ^ 2))
            PRINT "The volume = "; V
            GOTO Again

            TotalArea:
            CLS
            INPUT "How long is the radius"; R
            INPUT "How tall is the cylinder"; H
            LET T = 2 * P * R (H + R)
            PRINT "The total area = "; T
            GOTO Again

            Again:
            PRINT
            INPUT "Another (Y/N)"; YN$
            IF YN$ = "Y" THEN GOTO Start
            IF YN$ = "y" THEN GOTO Start
            IF YN$ = "N" THEN GOTO 200
            IF YN$ = "n" THEN GOTO 200

            200 END
         
Download the program.

Back to top.


Take the quiz on QBasic geometry programs.  The quiz is very useful for either review or to see if you've really got the topic down.


Back
Site Map
Home
Next


Math for Morons Like Us -- Geometry: Computer Fun
/20991/textonly/geo/computer.html
© 1998 ThinkQuest Team 20991