Computer Science, asked by avinash3435, 1 year ago

Write a qbasic code to create a simple calculator for addition, subtraction,multipication and division operation

Answers

Answered by iitian2020
14
Hello.

1 CLS
COLOR 7
DIM NUM1 AS SINGLE
DIM NUM2 AS SINGLE
PRINT TAB(30); "A SIMPLE CALCULATOR "
DO WHILE REP$ <> "N"
    PRINT
    INPUT "ENTER FIRST NUMBER HERE"; NUM1
    PRINT
    INPUT "ENTER OPERATOR HERE"; OPERATOR$
    PRINT
    INPUT "ENTER SECOND NUMBER HERE"; NUM2
    PRINT

    CALL OPERAN(NUM1, OPERATOR$, NUM2) 'FOR OPERATORS

    INPUT "TO QUIT PRESS (N), TO CONTINUE PRESS ENTER"; REP$
    REP$ = UCASE$(REP$)
    GOTO 1
LOOP

COLOR 4
LOCATE 23: PRINT TAB(30); "@ Jackieriel-Soft 2016, 08114137088 08131327382"

SUB OPERAN (NUM1, OPERATOR$, NUM2)
COLOR 2
PRINT NUM1; OPERATOR$; NUM2; "=";
IF OPERATOR$ = "+" THEN
    PRINT NUM1 + NUM2
ELSE IF OPERATOR$ = "-" THEN
        PRINT NUM1 - NUM2
    ELSE IF OPERATOR$ = "*" THEN
            PRINT NUM1 * NUM2
        ELSE IF OPERATOR$ = "/" THEN
                PRINT NUM1 / NUM2
            ELSE
                COLOR 4
                PRINT " YOU HAVED ENTERED A WRONG OPERATOR SIGN"
                BEEP
            END IF
        END IF
    END IF
END IF
PRINT
CALL FOOTB


END SUB

SUB FOOTB
COLOR 4
LOCATE 23: PRINT TAB(20); "@ JACKIERIEL SOFT 2016, 08114137088, 08131327382"
COLOR 7

END SUB

After you are done with the code press "F5" to run the program.

Hope it helps.
Answered by aniket3098
2

Explanation:

1 CLS

COLOR 7

DIM NUM1 AS SINGLE

DIM NUM2 AS SINGLE

PRINT TAB(30); "A SIMPLE CALCULATOR "

DO WHILE REP$ <> "N"

PRINT

INPUT "ENTER FIRST NUMBER HERE"; NUM1

PRINT

INPUT "ENTER OPERATOR HERE"; OPERATOR$

PRINT

INPUT "ENTER SECOND NUMBER HERE"; NUM2

PRINT

CALL OPERAN(NUM1, OPERATOR$, NUM2) 'FOR OPERATORS

INPUT "TO QUIT PRESS (N), TO CONTINUE PRESS ENTER"; REP$

REP$ = UCASE$(REP$)

GOTO 1

LOOP

COLOR 4

LOCATE 23: PRINT TAB(30); "@ Jackieriel-Soft 2016, 08114137088 08131327382"

SUB OPERAN (NUM1, OPERATOR$, NUM2)

COLOR 2

PRINT NUM1; OPERATOR$; NUM2; "=";

IF OPERATOR$ = "+" THEN

PRINT NUM1 + NUM2

ELSE IF OPERATOR$ = "-" THEN

PRINT NUM1 - NUM2

ELSE IF OPERATOR$ = "*" THEN

PRINT NUM1 * NUM2

ELSE IF OPERATOR$ = "/" THEN

PRINT NUM1 / NUM2

ELSE

COLOR 4

PRINT " YOU HAVED ENTERED A WRONG OPERATOR SIGN"

BEEP

END IF

END IF

END IF

END IF

PRINT

CALL FOOTB

END SUB

SUB FOOTB

COLOR 4

LOCATE 23: PRINT TAB(20); "@ JACKIERIEL SOFT 2016, 08114137088, 08131327382"

COLOR 7

END SUB

Similar questions