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

И пусть теперь все получиться! #1

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
maxshef wants to merge 5 commits into main
base: main
Choose a base branch
Loading
from dev
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# Пустой репозиторий для работы с Java кодом в Android Studio
И пусть все получиться!
Copy link

@ilshat-abdulin ilshat-abdulin May 13, 2023

Choose a reason for hiding this comment

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

👍👍

45 changes: 45 additions & 0 deletions src/main/java/Farmaterr.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import java.util.Scanner;
public class Farmaterr {
public String formatRub(int howPeople, double finalProductPrice) {
//double finalScorePeople = finalProductPrice / howPeople;
String RUB;
//String RUB2;
int endingRubles = (int) finalProductPrice;// % 100 / 10;
//int endingRubles = (int) finalScorePeople;// % 100 / 10;
if (endingRubles % 100 >= 11 && endingRubles % 100 <= 14) {
RUB = "рублей";
} else
switch (endingRubles % 10) {
case 1:
RUB = "рубль";
break;
case 2:
case 3:
case 4:
RUB = "рубля";
break;
default:
RUB = "рублей";
break;
}
return RUB;
}
}
// if (endingRubles2 % 100 >= 11 && endingRubles2 % 100 <= 14) {
// RUB2 = "рублей";
// } else
// switch (endingRubles2 % 10){
// case 1:
// RUB2 = "рублю";
// break;
//case 2:
//case 3:
//case 4:
// RUB2 = "рубля";
// break;
//default:
// RUB2 = "рублей";
// break;
//}
//}

29 changes: 26 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,29 @@

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
Scanner scanner = new Scanner(System.in);
ProductFeatures productFeatures = new ProductFeatures (); //объект класса ProductFeatures
Farmaterr farmaterr = new Farmaterr ();//объект класса Farmaterr
int howPeople = 0;
String chek4num;
while (howPeople <=1){
System.out.println("Сколько счетов у Вас будет?");
try {
chek4num = scanner.nextLine();
howPeople = Integer.parseInt(chek4num);
}
catch (Exception error){
System.out.println("Введите чиловое значение больше 1");
}
}
System.out.println("Счет будет разделен на:" + howPeople);
productFeatures.product(scanner);
//farmaterr.formatRub();
double finalScorePeople = productFeatures.finalProductPrice / howPeople;
String RUB = farmaterr.formatRub(howPeople, productFeatures.finalProductPrice);
System.out.println("Список продуктов:\n"+productFeatures.listProducts+"\n");
String format = "Общая стоимость составила: %.2f "+RUB+ "\nс каждого по:";
//String format = "Общая стоимость составила: %.2f "+RUB+ "\nс каждого по: %.2f " +RUB+".";
System.out.println(String.format(format, productFeatures.finalProductPrice));
}
}
}
32 changes: 32 additions & 0 deletions src/main/java/ProductFeatures.java
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.Scanner;
public class ProductFeatures {
double finalProductPrice = 00.00;
double productPrice = 00.00;
String listProducts = "";
public void product(Scanner scanner) {
while (productPrice <= 0 ) {
System.out.println("Введите название товара");
String product = scanner.next();
listProducts += product + "\n";
System.out.println("Введите цену товара в формате ХХ,ХХ");
String chekProductPrice = null;
double productPrice = 0;
try {
chekProductPrice = scanner.nextLine();
productPrice = Integer.parseInt(chekProductPrice);
}
catch (Exception error) {
System.out.println("Введена неверная цена, цена должна быть больше 0.00");
}

System.out.println("Хотите продолжить ввод товаров или введите завершить");
finalProductPrice = finalProductPrice + productPrice;
String complete = scanner.next();
if (complete.equalsIgnoreCase("Завершить")) {
System.out.println("Добавление товаров завершено, произведен расчет:");
break;
}
}
}
}

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