Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

String Equation Solver

I wanted to post something on this website, and this is just something I made awhile back. You pass an equation to it as a string (ex: "5+-5*3-(2+2*(-422+2)*5)-51/-2", and it returns 4213.5 😉

image :
htt p://i.imgur.co m/z0wbGTT.png

code :
htt p://pastebin.co m/4v11L7AH

It is perfectly accurate, however, it is kinda inefficient. I was 15 when I coded this, well still 15, but ill be 16 tomorrow! So my birthday revolution is making more efficient code 😁

Its original purpose was for project that takes scratch.mit games/applications, and converts them into .jar and .apk executables. However, Java has string equation solving, and its a ton faster 🤣 If I had to do this again, I'd probably tackle it with a token system method, much like RPM calculators, instead of parsing strings.

Have fun with the code though, and skype me at LucasHeer715, if you need any help.


Sorry it wouldn't let me post picture or code, because of my amount of posts :'(
happy birthday :D
just random text here
Ahh, i like these lil things. i can help you make it perfect if you want. i got the perfect methods i wrote to do so.
[Image: z0wbGTT.png]

Code:
http://pastebin.com/4v11L7AH


Anyways I suggest you do a more OOP approach, make a parser to parse the equation into segments (PEMDAS) and then solve them and use recursion to parse them again, etc.
I will probably go with that type of approach on my next try. I am happy with the accuracy of my equation solver, but I am not happy with the speed. It solves over 1000 times slower than compiled .net..

Thanks for uploading the pic and pastebin though! :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by AzythumOct 11, 2021 02:01 PM 8 394 Oct 11, 2021 02:01 PM
Last Post: Flegias
[C] by saltycrackerDec 14, 2020 09:35 AM 13 313 Dec 14, 2020 09:35 AM
Last Post: saltycracker
[C] by MordiciaNov 15, 2019 07:21 PM 3 211 Nov 15, 2019 07:21 PM
Last Post: Mordicia