Actually its true that QBaic is quite old and it cannot meet today's standards but the truth is that it is still good as an introduction to programming. I also learnt QBasic for two weeks before I moved to other languages like Java and C++.
I don't blame the people who are making jest of you and at the same time, i blame them because they were only making mouth and they didn't solve your problem. probably they do not no the solution to your problem. I have attached my own personal complete source code and a QBasic interpreter to this post. The source code is CALCULAT.BAS and the QBasic program is QBASIC.EXE
You can also copy the source code from here. This code is one of the work i did in those days, but to keep up with today's standards, i now developed Calculator+.exe which I developed with Java.
REM CALCULATOR DEVELOPED BY OLADEJI OLUWASAYO
REM PRESS F5 ON YOUR KEYBOARD TO RUN THE PROGRAM
REM To operate the calculator input the first number, press enter, input the operation to perform(i.e + - * / sin because tan ^ &), press enter, then input the second number and press enter.
REM + means plus
REM - means minus
REM * means multiply
REM / means divide
REM ^ means raised to the power of(exponential)
REM & means root (e.g square root, cube root, till any number root)
CLS
SCREEN 12
COLOR 15
CIRCLE (50, 50), 90
COLOR 14
CIRCLE (50, 350), 90
COLOR 9
CIRCLE (640, 50), 90
COLOR 5
CIRCLE (640, 350), 90
COLOR 3
CIRCLE (300, 200), 50
COLOR 15
CIRCLE (400, 500), 70
COLOR 12
CIRCLE (260, 420), 60
LINE (100, 100)-(200, 120), 15, BF
LINE (100, 120)-(120, 200), 15, BF
LINE (120, 180)-(200, 200), 15, BF
LINE (180, 200)-(200, 280), 15, BF
LINE (180, 260)-(100, 280), 15, BF
LINE (220, 100)-(240, 280), 15, BF
LINE (300, 100)-(320, 280), 15, BF
LINE (240, 100)-(300, 120), 15, BF
LINE (240, 180)-(300, 200), 15, BF
LINE (340, 100)-(360, 200), 15, BF
LINE (420, 100)-(440, 200), 15, BF
LINE (380, 200)-(400, 280), 15, BF
LINE (360, 180)-(420, 200), 15, BF
LINE (460, 100)-(560, 280), 15, BF
LINE (480, 120)-(540, 260), 0, BF
SOUND 300, 5
SOUND 500, 5
SOUND 700, 5
SOUND 900, 5
SOUND 1100, 5
SOUND 1300, 5
SOUND 1500, 5
SOUND 1700, 5
INPUT "press enter to continue"; ENTER
45 DIM A AS DOUBLE
DIM OPERATION AS STRING
DIM B AS DOUBLE
DIM RESULT AS SINGLE
DIM CONT AS STRING
CONST PI = 3.141592654#
CLS
COLOR 10
PRINT "CALCULATOR"
PRINT " "
INPUT A
INPUT OPERATION
INPUT B
IF OPERATION = "+" THEN
RESULT = A + B
PRINT A; " PLUS "; B; " = "; RESULT
END IF
IF OPERATION = "-" THEN
RESULT = A - B
PRINT A; " MINUS "; B; " = "; RESULT
END IF
IF OPERATION = "*" THEN
RESULT = A * B
PRINT A; " MULTIPLIED BY "; B; " = "; RESULT
END IF
IF OPERATION = "/" THEN
RESULT = A / B
PRINT A; " DIVIDED BY "; B; " = "; RESULT
END IF
IF OPERATION = "^" THEN
RESULT = A ^ B
PRINT A; " RAISED TO POWER "; B; " = "; RESULT
END IF
IF OPERATION = "&" THEN
RESULT = B ^ (1 / A)
PRINT A; " ROOT "; B; " = "; RESULT
END IF
IF OPERATION = "SIN" THEN
RESULT = A * (SIN(B * (PI / 180)))
PRINT A; " MULTIPLIED BY SIN "; B; " = "; RESULT
END IF
IF OPERATION = "COS" THEN
RESULT = A * (COS(B * (PI / 180)))
PRINT A; " MULTIPLIED BY COS "; B; " = "; RESULT
END IF
IF OPERATION = "TAN" THEN
RESULT = A * (TAN(B * (PI / 180)))
PRINT A; " MULTIPLIED BY TAN "; B; " = "; RESULT
END IF
IF OPERATION = "+" OR OPERATION = "-" OR OPERATION = "*" OR OPERATION = "/" OR OPERATION = "^" OR OPERATION = "&" OR OPERATION = "SIN" OR OPERATION = "COS" OR OPERATION = "TAN" THEN
PRINT " "
ELSE
PRINT "INVALID OPERATION"
END IF
INPUT "press enter to continue"; ENTER
CLS
INPUT "DO YOU WANT TO CONTINUE (Y or N)"; CONT
IF CONT = "Y" THEN
GOTO 45
ELSE
END
END IF
REM
This is the end of the code.To operate the calculator input the first number, press enter, input the operation to perform(i.e + - * / sin because tan ^ &), press enter, then input the second number and press enter.
+ means plus
- means minus
* means multiply
/ means divide
^ means raised to the power of(exponential)
& means root (e.g square root, cube root, till any number root)
If you have any problems on programming, contact
marvelindaclub@yahoo.compeace out,
-Sayo Oladeji
