Skip to content

Conversation

@yarikpavlin
Copy link

3 task will be done soon

@didva didva self-assigned this Nov 28, 2016
boolean start = true;
while (start) {
System.out.println("Make your choice.");
Scanner sc = new Scanner(System.in);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating scanner in each iteration is not a good idea.


private static void exit() {
System.out.println("Bye-bye");
System.exit(0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bad practice to use System.exit(). Please get rid of it.


}

private static void help() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about help message?

System.out.println("Make your choice.");
Scanner sc = new Scanner(System.in);
String choice = sc.nextLine();
choice.toLowerCase();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not working properly because string is immutable. Please read documentation about string methods.

case "help":
help();
break;
default:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer print help message by default.

System.out.println("Enter second number:");
b = sc.nextInt();
result = a / b;
System.out.println("Result of " + a + "/" + b + " is " + result);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use String.format

System.exit(0);
}

private static void div() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are too many duplicated code... Reading two integers for example. Maybe you can get rid of it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants