forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuests.java
More file actions
22 lines (21 loc) · 847 Bytes
/
Guests.java
File metadata and controls
22 lines (21 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class Guests {
public int guestsNum(){
int guestsNum = 0;
Scanner scanner = new Scanner(System.in);
do {
System.out.println("На какое количество человек хотите разделить счёт? (цифрой)");
if(scanner.hasNextInt()) {
guestsNum = scanner.nextInt();
if (guestsNum == 1) {
System.out.println("Нет смысла делить счёт!");
scanner.nextLine();
}
} else {
scanner.nextLine();
System.out.println("Пожалуйста, введите корректное количество гостей!");
}
} while(guestsNum<=1);
return guestsNum;
}
}