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

ураааа #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
neverovamarta wants to merge 1 commit into main
base: main
Choose a base branch
Loading
from neww
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 58 additions & 3 deletions src/main/java/Main.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,61 @@

import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");

ArrayList<String> schets = new ArrayList<>();
ArrayList<Float> sum = new ArrayList<>();
System.out.println("Добро пожаловать в наше заведение! На скольких человек необходимо разделить ваш счёт?");
Scanner scanner = new Scanner(System.in);
int otw = scanner.nextInt();
while (otw < 2) {
System.out.println("Для использования нашего приложения необходимо не менее двух посетителей, пожалуйста, повторите попытку.");
otw = scanner.nextInt();
}

for (int i = 1; i <= otw; ++i) {
String naz;
float sch = 0;
ArrayList<String> eda = new ArrayList<>();
System.out.printf("Пользователь номер %d, укажите название товара, которое вы хотите заказать, и его стоимость на следующей строке.", i);
naz = scanner.next();
while (!(naz.equalsIgnoreCase("Завершить"))) {
float summ = scanner.nextFloat();
sch = summ + sch;
eda.add(naz);
System.out.printf("Товар '%s' успешно добавлен в счёт!", naz);
System.out.printf("Пользователь номер %d, укажите название товара, которое вы хотите заказать, и его стоимость на следующей строке. Если вы больше не хотите ничего заказывать, напишите 'Завершить'.", i);
naz = scanner.next();
}
schets.add(String.valueOf(eda));
sum.add(sch);
eda.clear();
}

for (int i = 0; i < otw; i++) {
System.out.printf("Пользователь номер %d, ваши добавленные товары:", i + 1);
ArrayList<String> s = new ArrayList<>();
s.add(schets.get(i));

for (String ed : s) {
System.out.println(ed);
}

int okr = (int)Math.floor(sum.get(i));
int ost = okr % 10;
int ostt = okr % 100;
String str = String.format("%d", okr);

if (((4 < ost) && (okr <= 20)) || (okr == 11) || ((okr > 110) && (ost == 1))) {
System.out.printf("Ваша сумма: %.2f рублей\n", sum.get(i));
} else if (ost == 0) {
System.out.printf("Ваша сумма: %.2f рублей\n", sum.get(i));
} else if (str.contains("1") && okr <= 101 || ostt == 1){
System.out.printf("Ваша сумма: %.2f рубль\n", sum.get(i));
} else {
System.out.printf("Ваша сумма: %.2f рубля\n", sum.get(i));
}
s.clear();
}
}
}
}

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