forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
38 lines (31 loc) · 1.3 KB
/
Main.java
File metadata and controls
38 lines (31 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int persons = 5;
boolean isNumber = false;
while (!isNumber) {
System.out.println("На скольких человек необходимо разделить счёт?");// ваш код начнется здесь
if (scanner.hasNextInt()) {
persons = scanner.nextInt();
if (persons == 1) {
System.out.println("Нет смысла ничего считать и делить");
} else if (persons < 1) {
System.out.println("Это некорректное значение для подсчёта");
} else {
isNumber = true;
}
} else {
System.out.println("Это неправильное число!");
scanner.next();
}
}
Calculator calculator = new Calculator();
calculator.sumProduct();
System.out.println(calculator.listProduct);
double total = calculator.sum / persons;
Ruble ruble = new Ruble();
ruble.writeRuble(total);
System.out.println(ruble.amountOfRubles);
}
}