Создание программы "Калькулятор" с основными функциями, страница 2

CIRCLE (x + 150 + 10, y + 50), 20, col, 0, 1.57

LINE (x + 150 + 40, y + 50)-(x + 30 + 150, y + 50), col

LINE (x + 150 + 40, y)-(x + 150 + 30, y), col

PAINT (x + 35 + 150, y + 1), col, col

PAINT (x + 35 + 150, y + 49), col, col

LOCATE 12, 7: PRINT "Запуск программы"

LOCATE 14, 7: PRINT "Инструкция"

LOCATE 16, 7: PRINT "О программе"

LOCATE 18, 7: PRINT "Выход"

110 x = 12

COLOR 9

120 LOCATE x, 5: PRINT "█"

130 A$ = INKEY$

IF A$ = "" THEN 130

IF A$ = CHR$(13) THEN 200

IF A$ = CHR$(0) + CHR$(80) THEN LOCATE x, 5: PRINT " ": x = x + 2

IF x = 20 THEN 110

IF A$ = CHR$(72) THEN LOCATE x, 5: PRINT " ": x = x - 2

IF x = 10 THEN 110

GOTO 120

200 IF x = 12 THEN CLS : calk3

IF x = 14 THEN GOSUB 220

IF x = 16 THEN GOSUB 230

IF x = 18 THEN END

GOTO 100

220 CLS

LOCATE 2, 12: PRINT "Инструкция"

COLOR 1

LOCATE 4, 1: PRINT "1) Ввести число с помощью клавиатуры"

LOCATE 5, 1: PRINT "2) С помощью клавиш W (команда вверх),"

LOCATE 6, 21: PRINT "A (команда влево),"

LOCATE 7, 21: PRINT "S (команда вниз) и"

LOCATE 8, 21: PRINT "D (команда вправо)"

LOCATE 9, 2: PRINT "выбрать нужное арифметическое действие"

LOCATE 10, 1: PRINT "3) Потвердить выбор клавишей Enter,"

LOCATE 11, 1: PRINT "4) Повторить 1 пункт"

LOCATE 12, 1: PRINT "5) Получить результат,"

LOCATE 13, 2: PRINT "нажав одну из клавиш W,A,S,D"

LOCATE 14, 1: PRINT "6) При необходимости,"

LOCATE 15, 2: PRINT "повторить пункты 2-5 "

LOCATE 16, 1: PRINT "7) Выйти из программы,"

LOCATE 17, 2: PRINT "выбрав Арифметический знак = (равно)"

COLOR 12

GOSUB 99

RETURN

230 CLS

COLOR 9

LOCATE 2, 12: PRINT "О программе:"

COLOR 12

LOCATE 4, 1: PRINT "Calk v 1.0015"

LOCATE 6, 1: PRINT "Дата Создания: Май 2011г."

COLOR 9

LOCATE 8, 12: PRINT "Об Авторе:"

COLOR 12

LOCATE 10, 1: PRINT "Петров Дмитрий."

LOCATE 11, 1: PRINT "Ученик 11 класса школы 20, г.Владимира "

COLOR 9

LOCATE 13, 12: PRINT "Благодарности:"

COLOR 12

LOCATE 15, 1: PRINT "Выражаю Благодарность"

LOCATE 16, 1: PRINT "своему учителю Вороновой Т.Н."

LOCATE 17, 1: PRINT "и однокласснику  Панасюку А.Д."

LOCATE 18, 1: PRINT "за помощь при создании программы."

GOSUB 99

RETURN

99 IF INKEY$ = "" THEN 99

RETURN

END

SUB calk3

SCREEN 7

COLOR 13, 7

LOCATE 2, 15

PRINT "calk"

LINE (20, 15)-(240, 35), 15, BF

t = 25

S = 73

p = 21

l = 24

m = t

n = S

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 11, 5

PRINT "7"

n = S + l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 14, 5

PRINT "4"

n = S + 2 * l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 17, 5

PRINT "1"

n = S + 3 * l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 20, 5

PRINT "0"

m = t + l

n = S

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 11, 8

PRINT "8"

n = S + l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 14, 8

PRINT "5"

n = S + 2 * l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 17, 8

PRINT "2"

n = S + 3 * l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 20, 8

PRINT ","

m = t + 2 * l

n = S

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 11, 11

PRINT "9"

n = S + l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 14, 11

PRINT "6"

n = S + 2 * l

LINE (m, n)-(m + p, n + p), 8, BF

LOCATE 17, 11

PRINT "3"

n = S + 3 * l

LINE (m, n)-(m + p, n + p), 8, B

LOCATE 20, 11

PRINT "="

m = t + 3 * l

n = S

LINE (m, n)-(m + p, n + p), 8, B

LOCATE 11, 14

PRINT "/"

n = S + l

LINE (m, n)-(m + p, n + p), 8, B

LOCATE 14, 14

PRINT "X"

n = S + 2 * l

LINE (m, n)-(m + p, n + p), 8, B

LOCATE 17, 14

PRINT "-"

n = S + 3 * l

LINE (m, n)-(m + p, n + p), 8, B

LOCATE 20, 14

PRINT "+"

t = 25

S = 73

p = 21

l = 24

m = t

n = S

x = 1

y = 1

z = 0

30

C = 0

LINE (20, 15)-(240, 35), 15, BF

10 j$ = INPUT$(1)

k = ASC(j$)

nn = 0

IF k = 46 THEN

50 j$ = INPUT$(1)

k = ASC(j$)

IF k > 47 AND k < 58 THEN

nn = nn + 1

C = C + (k - 48) * 10 ^ -nn

LOCATE 4, 4

PRINT C

GOTO 50

END IF

END IF

IF k > 47 AND k < 58 THEN

C = C * 10 + k - 48

LOCATE 4, 4

PRINT C

GOTO 10

END IF

IF k = 119 OR k = 97 OR k = 115 OR k = 100 THEN GOTO 15 ELSE 10

15

IF r = 0 THEN GOTO 20

IF z = 1 THEN GOTO 25

IF z = 2 THEN GOTO 26

IF z = 3 THEN GOTO 27

IF z = 4 THEN GOTO 28

GOTO 10

20

LINE (m, n)-(m + p, n + p), 11, B

j$ = INPUT$(1)

v = ASC(j$)

IF v = 115 AND n < S + 3 * l THEN

LINE (m, n)-(m + p, n + p), 8, B

n = n + l

y = y + 1

END IF

IF v = 119 AND n > S THEN

LINE (m, n)-(m + p, n + p), 8, B

n = n - l

y = y - 1

END IF

IF v = 100 AND m < t + 3 * l THEN

LINE (m, n)-(m + p, n + p), 8, B

m = m + l

x = x + 1

END IF

IF v = 97 AND m > t THEN

LINE (m, n)-(m + p, n + p), 8, B

m = m - l

x = x - 1

END IF

IF v <> 13 THEN GOTO 20

IF v = 13 AND x = 4 AND y = 4 THEN

z = 1

r = C

GOTO 30

25 r = r + C

LOCATE 4, 4

PRINT r

C = r

GOTO 20

END IF

IF v = 13 AND x = 3 AND y = 4 THEN

PLAY "O5 L4 T255 C D E F. "

GOTO 420

'END

END IF

IF v = 13 AND x = 4 AND y = 3 THEN

z = 2

r = C

GOTO 30

26 r = r - C

LOCATE 4, 4

PRINT r

C = r

GOTO 20

END IF

IF v = 13 AND x = 4 AND y = 2 THEN

z = 3

r = C

GOTO 30

27 r = r * C

LOCATE 4, 4

PRINT r

C = r

GOTO 20

END IF

IF v = 13 AND x = 4 AND y = 1 THEN

z = 4

r = C

GOTO 30

28 r = r / C

LOCATE 4, 4

PRINT r

C = r

GOTO 20

END IF

GOTO 20

420

END SUB

Используемая литература

1.  А.Г. Гейн «Основы информатики и вычислительной техники»

2.  Григорий Зельднер «Quick Basic для носорога» М. 1999