forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
И пусть теперь все получиться! #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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4ba7466
И пусть теперь все получиться!
maxshef a82a0f7
И пусть теперь все получиться!
maxshef 6696530
И пусть теперь все получиться!_v1.1 промежуточная
maxshef 5acdece
И пусть теперь все получиться!_v1.2 промежуточная
maxshef 8a45e10
И пусть теперь все получиться!_v1.2 промежуточная
maxshef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| # Пустой репозиторий для работы с Java кодом в Android Studio | ||
| И пусть все получиться! | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍 |
||
45 changes: 45 additions & 0 deletions
src/main/java/Farmaterr.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.