Windows 10 For CC:Tweaked Calc

Started by Krittanai, Dec 05, 2024, 06:06 AM

Previous topic - Next topic

Krittanai

This Is My Calc Program Code

For My Other Porject https://forums.computercraft.cc/index.php?topic=683.0

term.setCursorPos(1,1)
term.clear()
local function add(x, y)
  return x + y
end
local function subtract(x, y)
  return  x - y
end
local function multiply(x, y)
  return x * y
end
local function divide(x, y)
  if y == 0 then
    return "Error! 0/0 Is Impossple Equasion."
  else
    return x / y
  end
end
local function modulo(x, y)
  return x % y
end
local function exponentiation(x, y)
  return x ^ y
end
print("Enter the first number:")
local num1 = tonumber(read())
print("Enter the second number:")
local num2 = tonumber(read())
print("Enter the operation (+, -, *, / ,% ,^):")
local operator = read()
local result
if operator == "+" then
  result = add(num1, num2)
elseif operator == "-" then
  result = subtract(num1, num2)
elseif operator == "*" then
  result = multiply(num1, num2)
elseif operator == "/" then
  result = divide(num1, num2)
elseif operator == "%" then
  result = modulo(num1, num2)
elseif operator == "^" then
  result = exponentiation(num1, num2)
else

  result = "Invalid operator!"
  end
print("Result:", result)

A Good Calc Program


Krittanai

Im Planing To Make More Opretors