SHOW:
|
|
- or go back to the newest paste.
| 1 | term.clear() | |
| 2 | term.setCursorPos(1,1) | |
| 3 | print"The Calculator Will Produce An Error If You Input A Letter Or Any Character Apart From A Number And A Dot" | |
| 4 | sleep(2) | |
| 5 | sin = 0 | |
| 6 | function menu(text, id) | |
| 7 | if sin == id then | |
| 8 | write("[ "..text.." ]")
| |
| 9 | else | |
| 10 | write(" "..text.." ")
| |
| 11 | end | |
| 12 | print"" | |
| 13 | end | |
| 14 | term.clear() | |
| 15 | term.setCursorPos(1,1) | |
| 16 | print"Enter First Number" | |
| 17 | write"" | |
| 18 | input = tonumber(read()) | |
| 19 | term.clear() | |
| 20 | term.setCursorPos(1,1) | |
| 21 | print"Select A Symbol" | |
| 22 | while true do | |
| 23 | term.setCursorPos(1,4) | |
| 24 | menu("+ ", 0)
| |
| 25 | menu("- ", 1)
| |
| 26 | menu("/ ", 2)
| |
| 27 | menu("* ", 3)
| |
| 28 | menu("^ ", 4)
| |
| 29 | menu("/^", 5)
| |
| 30 | ||
| 31 | local event, key = os.pullEvent("key")
| |
| 32 | if key == 208 then | |
| 33 | if sin > 4 then | |
| 34 | sin = sin - 5 | |
| 35 | else | |
| 36 | sin = sin + 1 | |
| 37 | end | |
| 38 | elseif key == 200 then | |
| 39 | if sin < 1 then | |
| 40 | sin = sin + 5 | |
| 41 | else | |
| 42 | sin = sin - 1 | |
| 43 | end | |
| 44 | elseif key == 28 then | |
| 45 | if sin == 0 then | |
| 46 | term.clear() | |
| 47 | term.setCursorPos(1,1) | |
| 48 | print"Enter Second Number" | |
| 49 | write"" | |
| 50 | input2 = tonumber(read()) | |
| 51 | output = input2 + input | |
| 52 | term.clear() | |
| 53 | term.setCursorPos(1,1) | |
| 54 | print(output.." Press Enter To Continue") | |
| 55 | while true do | |
| 56 | event, key = os.pullEvent("key")
| |
| 57 | if key == 28 then | |
| 58 | term.clear() | |
| 59 | term.setCursorPos(1,1) | |
| 60 | return | |
| 61 | end | |
| 62 | end | |
| 63 | end | |
| 64 | if sin == 1 then | |
| 65 | term.clear() | |
| 66 | term.setCursorPos(1,1) | |
| 67 | print"Enter Second Number" | |
| 68 | write"" | |
| 69 | input2 = tonumber(read()) | |
| 70 | output = input - input2 | |
| 71 | term.clear() | |
| 72 | term.setCursorPos(1,1) | |
| 73 | print(output.." Press Enter To Continue") | |
| 74 | while true do | |
| 75 | event, key = os.pullEvent("key")
| |
| 76 | if key == 28 then | |
| 77 | term.clear() | |
| 78 | term.setCursorPos(1,1) | |
| 79 | return | |
| 80 | end | |
| 81 | end | |
| 82 | end | |
| 83 | if sin == 2 then | |
| 84 | term.clear() | |
| 85 | term.setCursorPos(1,1) | |
| 86 | print"Enter Second Number" | |
| 87 | write"" | |
| 88 | input2 = tonumber(read()) | |
| 89 | output = input / input2 | |
| 90 | term.clear() | |
| 91 | term.setCursorPos(1,1) | |
| 92 | print(output.." Press Enter To Continue") | |
| 93 | while true do | |
| 94 | event, key = os.pullEvent("key")
| |
| 95 | if key == 28 then | |
| 96 | term.clear() | |
| 97 | term.setCursorPos(1,1) | |
| 98 | return | |
| 99 | end | |
| 100 | end | |
| 101 | end | |
| 102 | if sin == 3 then | |
| 103 | term.clear() | |
| 104 | term.setCursorPos(1,1) | |
| 105 | print"Enter Second Number" | |
| 106 | write"" | |
| 107 | input2 = tonumber(read()) | |
| 108 | output = input2 * input | |
| 109 | term.clear() | |
| 110 | term.setCursorPos(1,1) | |
| 111 | print(output.." Press Enter To Continue") | |
| 112 | while true do | |
| 113 | event, key = os.pullEvent("key")
| |
| 114 | if key == 28 then | |
| 115 | term.clear() | |
| 116 | term.setCursorPos(1,1) | |
| 117 | return | |
| 118 | end | |
| 119 | end | |
| 120 | end | |
| 121 | if sin == 4 then | |
| 122 | term.clear() | |
| 123 | term.setCursorPos(1,1) | |
| 124 | print("Enter Second Number")
| |
| 125 | write"" | |
| 126 | input2 = tonumber(read()) | |
| 127 | output = input^input2 | |
| 128 | term.clear() | |
| 129 | term.setCursorPos(1,1) | |
| 130 | print(output.." Press Enter To Continue") | |
| 131 | while true do | |
| 132 | event, key = os.pullEvent("key")
| |
| 133 | if key == 28 then | |
| 134 | term.clear() | |
| 135 | term.setCursorPos(1,1) | |
| 136 | return | |
| 137 | end | |
| 138 | end | |
| 139 | end | |
| 140 | if sin == 5 then | |
| 141 | term.clear() | |
| 142 | term.setCursorPos(1,1) | |
| 143 | print("Enter Second Number")
| |
| 144 | input2 = tonumber(read()) | |
| 145 | output = input^(1/input2) | |
| 146 | term.clear() | |
| 147 | term.setCursorPos(1,1) | |
| 148 | print(output.." Press Enter To Continue") | |
| 149 | while true do | |
| 150 | event, key = os.pullEvent("key")
| |
| 151 | if key == 28 then | |
| 152 | term.clear() | |
| 153 | term.setCursorPos(1,1) | |
| 154 | return | |
| 155 | end | |
| 156 | end | |
| 157 | end | |
| 158 | ||
| 159 | end | |
| 160 | end |