Share your repls and programming experiences

← Back to all posts
i made a calculator, nothing special
h
dbednar230

the first thing I made in java. basically the starter project for every new language.

Voters
raf024
Pinhead69
ElizabethLamade
Embedded77
0tt0296
BoiKane
Darkgamer23
JamesMercado
dbednar230
Comments
hotnewtop
Pinhead69

Ah, I see you're a man of culture as well

[deleted]

Good work. You might like to split your logic up a bit more by creating functions that:
1. Get a number
2. Get the operator
3. Do the calculation
4. Handle the calling of the above functions in the right order

It's a rule of thumb that functions should do just one thing. This makes them more reusable and helps prevent too complicated logic. Your openval function does several.

dbednar230

@malvoliothegood done! didn't realize my mistake there, just tried to make this as fast as possible