Java Programming - Making a Basic Calculator

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I just want to point out that there are a few problems with this program. You have several variables that are declared to be static, but since only one class is using these variables, it is better to declare and initialize the variables inside the main method. Also, your selection statements have several repeated pieces of code. Just some advice for people who see this program, common statements among all conditions of a selection statement should not be repeated. This program could've been made more efficient had the statements for user input been placed before the condition. Other than that this program was a very good introduction and worked smoothly!

BhaveshKemburu
Автор

Instead of making them input a number, couldn't you make a char sign; variable and then prompt the question for what sign and do if/ else if statements saying if(sign == 'x') *x being any operator* ?

kycatsjeffrey
Автор

why do we make int op = 0? we've got scanner to input values into op dont we?

daniilkostromin