Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Проектная работа#1

Open
aNikeevaAlina wants to merge 3 commits intomain from
dev
Open

Проектная работа #1
aNikeevaAlina wants to merge 3 commits intomain from
dev

Conversation

@aNikeevaAlina
Copy link
Owner

@aNikeevaAlina aNikeevaAlina commented Feb 5, 2023

Консольное приложение No1

System.out.println("На скольких человек необходимо рзделить счет?");
try {
countGuest = scanner.nextInt();
} catch (InputMismatchException er) {
Copy link

@gusar-off gusar-off Feb 5, 2023

Choose a reason for hiding this comment

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

Удобнее вместо отлавливания ошибки воспользоваться готовым методом scanner.hasNextInt()


String strPriceProduct = scanner.next();
try {
product.price = Double.parseDouble(strPriceProduct);
Copy link

@gusar-off gusar-off Feb 5, 2023

Choose a reason for hiding this comment

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

У Scanner есть удобный метод hasNextDouble, можно сразу узнать без дополнительных проверок возможно ли интерпретировать строку как double https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html#hasNextDouble%28%29

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

Reviewers

1 more reviewer

@gusar-off gusar-off gusar-off left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /