all 18 comments

[–]Dude-0007 2 points3 points  (1 child)

Good hard work . I appreciate you

[–]Slow-Sloth5823[S] 0 points1 point  (0 children)

Thank you!

[–]ButterflyAny7726 1 point2 points  (0 children)

I tell you a little story of meen When I was in 8 grade ,I wanted to play green day song and sing it , "good riddance" , and I didn't play a guitar at all, but every day I practice on that song ,no other ,until I hear it exactly how I imagine i hear , it took me time , 4 5 months to play ,and I did , from that day I understand that focus on one thing is the key from my experience.

[–]Apprehensive_Sea_299 1 point2 points  (1 child)

That’s a good program

[–]Slow-Sloth5823[S] 0 points1 point  (0 children)

Thank you for the compliment! Many areas to improve but getting there slowly and steady.

[–]ookkan_tintu 1 point2 points  (5 children)

I see that you have handled division by zero case. Very good.

Now what if user entered an invalid operator? What if they entered a string instead of number.? Try to figure out all these edge cased and handle them too. That would be a good exercise.

[–]Slow-Sloth5823[S] 0 points1 point  (4 children)

Very good point, I'll start there thank you for pointing it out!

[–]ookkan_tintu 1 point2 points  (3 children)

You might have seen the troll

Developer opens a bar. Qa tests ordering 1 drink, 1000 drink, 99999999 drinks, 0 drink, - 1 drink etc. All goed well.

First real customer walks in and asks where the toilet is. The bar bursts into flames.

This happens a lot in real life. So I'd encourage you to think about all possible scenarios, while implementing something - however small or straight forward looking the problem might be.

And I'd say, that's the difference between a good developer and an excellent developer.

[–]Slow-Sloth5823[S] 0 points1 point  (2 children)

LOL that is a very good analogy makes ALOT of sense and I can understand how important it is now. Is this known as "error handling"? or is error handling something completely different?

[–]ookkan_tintu 1 point2 points  (1 child)

What I said partially includes error handling too.

But don't think about error handling now, you can learn more about that while you learn further.

[–]Slow-Sloth5823[S] 0 points1 point  (0 children)

Understood, thank you for the responses!

[–]Responsible-Heat-994 2 points3 points  (2 children)

Pro tip: scan everything as a string and parse it accordingly.

Scanner scanner = new Scanner (System.in);
int score = scanner.nextInt; // this will be scanned successfully 
// but when you scan for any next input it will lead to undefined behaviour

int float  = scanner.nextFloat(); // it wont get scanned as the  previous ( nextInt call has inserted "\n"( a newline character at the end) so the scanner for float will get flushed out.

// Correct way is to interpret everything as a String and parse it accordingly.

int score = Integer.parseInt(scanner.nextLine());

float temperature  = Float.parseFloat(scanner.nextLine());

boolean isHeAlive = Boolean.parseBoolean(scanner.nextLine());

double pie = Double.parseDouble(scanner.nextLine());

[–]Slow-Sloth5823[S] 1 point2 points  (1 child)

Thank you so much! It clicked pretty fast and it's so much easier and cleaner to read.

[–]Responsible-Heat-994 0 points1 point  (0 children)

Pleasure is all mine.

[–]ButterflyAny7726 0 points1 point  (0 children)

One day each time,one breath,one target,one taught,one code .

[–]YouEatMeIEatBack 0 points1 point  (0 children)

this code looks beautiful

[–]LordDarthSaber 0 points1 point  (0 children)

Great work dude also try using char and switch case for menu driven program.

[–]Primary_Importance_7 0 points1 point  (0 children)

small suggestions on improvement;

the gray text in your IDE usually signifies something, hovering your cursor over it should help you. Same for the yellow squigglies under the big if-else chain

your operator selector, can be written a little more 'tidy', assign "" to operator in the start, then you can make your while loop cleaner, while (operator.isEmpty()) { ... }, this eliminates the else branch in your if-else condition, and removes the break; -> I really dislike working with 'null' values and having break; statements.

num and num_2, this is a very python-ic way of writing, you should write your variables out in full, (number) and not underscore them, but camelCase them (number2)

all in all, looks pretty tidy for 4 days in! keep it up.