For the sake of it I will post my program to see if you could add in an algebraic-solving section to it:
Code: Select all
REM This is incomplete, so don't be alarmed if you see a "goto" string that goes to a tag that does not exist. :)
@echo off
setlocal enableextensions
setlocal enabledelayedexpansion
:menu
color 1e
title Calculator
cls
echo MENU:
echo 1. Simple Calculations
echo 2. Intermediate Calculations
echo 3. Algebra
echo 4. Angles
echo 5. About
echo 6. Help
echo 7. Exit
echo _______
set /p a=I CHOICE:
if /i _"%a%"==_"1" (goto :simple)
if /i _"%a%"==_"2" (goto :harder)
if /i _"%a%"==_"3" (goto :algebra)
if /i _"%a%"==_"4" (goto :angles)
if /i _"%a%"==_"5" (goto :about)
if /i _"%a%"==_"6" (goto :help)
if /i _"%a%"==_"7" (goto :eof)
goto :fault
:fault
echo You entered an illegal choice. Please enter correct choices when prompted.
timeout /t 2 /nobreak >nul
goto :menu
REM SIMPLE MATHEMATICS FROM HERE:
:simple
cls
echo Options:
echo 1. Addition
echo 2. Subtraction
echo 3. Multiplication
echo 4. Division
echo 5. Go to menu.
echo _______
set /p a=I CHOICE:
if /i _"%a%"==_"1" (goto :add)
if /i _"%a%"==_"2" (goto :take)
if /i _"%a%"==_"3" (goto :times)
if /i _"%a%"==_"4" (goto :divide)
if /i _"%a%"==_"5" (goto :menu)
goto :fault
:add
:redo
cls
set /p "A= Enter first number:"
set /p "B= Enter second number:"
if /i _"%B%"==_"back" (goto :redo)
set "C=%A%+%B%" & call :simpleanswer
goto :simple
:take
:redo2
cls
set /p "A= Enter first number:"
set /p "B= Enter second number:"
if /i _"%B%"==_"back" (goto :redo2)
set "C=%A%-%B%" & call :simpleanswer
goto :simple
:times
:redo4
cls
set /p "A= Enter first number:"
set /p "B= Enter second number:"
if /i _"%B%"==_"back" (goto :redo4)
set "C=%A%*%B%" & call :simpleanswer
goto :simple
:divide
:redo6
cls
set /p "A= Enter first number:"
set /p "B= Enter second number:"
if /i _"%B%"==_"back" (goto :redo6)
set "C=%A%/%B%" & call :simpleanswer
goto :simple
:simpleanswer
set /a D=%C%
echo %C%=%D%
pause >nul
REM INTERMEDIATE MATHEMATICS:
:harder
cls
echo Options:
echo 1. More Complex Maths
echo 2. Percentage
echo 3. (Kind of) Fractions
echo 4. Go to menu
echo _______
set /p a=I CHOICE:
if /i _"%a%"==_"1" (goto :complex)
if /i _"%a%"==_"2" (goto :%)
if /i _"%a%"==_"3" (goto :bits)
goto :fault
:%
cls
echo This function works out percentages. Do you want to continue?
set /p a=Enter lowercase y/n:
if /i _"%a%"==_"y" (goto :percent)
if /i _"%a%"==_"n" (goto :harder)
goto :fault
:bits
cls
:redo7
cls
set /p "A= Enter numerator 1:
set /p "B= Enter denominator 1:
if /i _"%B%"==_"back" (goto :redo7)
set "C=%A%/%B%"
set "1=10"
set "2=%B%/%1%"
set /a 3=%2%
set "4=%A%*%3%"
set /a "5=%4%"
REM %5% now holds percentage result of fraction 1
cls
:redo8
set /p "A= Enter numerator 2:
set /p "B= Enter denominator 2:
if /i _"%B%"==_"back" (goto :redo8)
set "C=%A%/%B%"
set "1=10"
set "2=%B%/%1%"
set /a "3=%2%"
set "6=%A%*%3%"
set /a "7=%6%"
REM %7% now holds percentage result of fraction 2
REM Now to combine them:
set "pre=%5%+%7%"
set /a answer=%pre%
REM %answer% now has the percentage of the added fractions.
echo The result is %answer%%.
pause >nul
goto :harder
:%
cls
:redo9
cls
set /p "A= Enter number:
set /p "B= Enter "out of":
if /i _"%B%"==_"back" (goto :redo9)
set "C=%A%/%B%"
set "1=10"
set "2=%B%/%1%"
set /a 3=%2%
set "4=%A%*%3%"
set /a 5=%4%
REM %5% now holds percentage result of fraction 1
echo The result is %answer%%.
pause >nul
goto :harder
:complex
cls
set /p A=Enter calculatory string:
set /a B=%A%
echo %B%
pause >nul
goto :harder
:algebra
echo Options:
echo 1. Solve for x
echo 2. Sovle equation
echo 3. Go to Menu
echo _________
set /p a=I CHOICE:
if /i _"%a%"==_"1" (goto :solvex)
if /i _"%a%"==_"2" (goto :solvee)
goto :fault
:solvex
echo Options:
echo 1. Simple algebra:
echo 2. More complex algebra:
echo 3. Go to Menu
echo _________
set /p a=I CHOICE:
if /i _"%a%"==_"1" (goto :simplea)
if /i _"%a%"==_"2" (goto :harda)
pause >nul
:simplea
cls
:redo12
cls
set /p A= Enter equation:
if /i _"%B%"==_"back" (goto :redo12)
set "C=%A%+%B%" & call :simpleanswer
goto :simple
Regards,
Rileyh