Share your repls and programming experiences

← Back to all posts
i made a calculator, nothing special
steamsydev (15)

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

Commentshotnewtop
malvoliothegood (430)

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.

steamsydev (15)

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

Pinhead69 (16)
if (result == 69 || result == 420 || result == 69420){
  System.out.println("funny number haha ecks dee");

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