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
35 lines (28 loc) · 1.32 KB
/
Main.java
File metadata and controls
35 lines (28 loc) · 1.32 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
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;
import java.util.Scanner;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
Calculator calculator;
calculator = new Calculator();
// Выясняем сколько платить
double PoSkolkoPlatit=calculator.start();
// выясняем какое окончание у "рубль"
String pravilno= calculator.roubleEnd(PoSkolkoPlatit);
//идем на извращения, дабы поменять точку на запятую.
// функция replace не работает и т.п. тоже не работают
if (PoSkolkoPlatit>0) {
DecimalFormat myFloatFormatter = new DecimalFormat("#.##");
String dolgStr = myFloatFormatter.format(PoSkolkoPlatit);
if (PoSkolkoPlatit-(int)PoSkolkoPlatit==0)
{dolgStr=dolgStr+",00";}
int zap = dolgStr.indexOf(",");
String part1 = dolgStr.substring(0, zap);
String part2 = dolgStr.substring(zap + 1, dolgStr.length());
// Выводим итог
System.out.println("Каждый должен заплатить по: " + part1 + "." + part2 + " " + pravilno);
}
}
}