Repository navigation
Первая проектная работа на Яндекс Практикум (Java) #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
Ded-Rinat
wants to merge
2
commits into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ sourceCompatibility = 1.8 | |
| version = '1.0' | ||
|
|
||
| repositories { | ||
|
|
||
| } | ||
|
|
||
| dependencies { | ||
|
|
||
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,24 @@ | ||
|
|
||
|
|
||
| public class Convert { | ||
|
|
||
| static String convertRub(double result) { | ||
| String rub="рубл"; | ||
|
|
||
| if ( result>=11 && result<=14) { | ||
| rub += "ей"; | ||
| }else { | ||
|
Ded-Rinat marked this conversation as resolved.
|
||
| result %= 10; | ||
| if (result == 1) { | ||
| rub += "ь"; | ||
| } else if (result >= 2 && result<= 4) { | ||
|
Ded-Rinat marked this conversation as resolved.
|
||
| rub += "я"; | ||
| } else { | ||
| rub += "ей"; | ||
| } | ||
| } | ||
| return rub; | ||
| } | ||
| } | ||
|
|
||
|
|
||
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,8 +1,53 @@ | ||
| public class Main { | ||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| // dev branch for Y.Practicum | ||
| public class Main { | ||
|
|
||
|
|
||
| public static void main(String[] args) { | ||
| // ваш код начнется здесь | ||
| // вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости | ||
| System.out.println("Привет Мир"); | ||
|
|
||
| int countPersons;//количество человек | ||
| Scanner scanner = new Scanner(System.in); | ||
| System.out.println("На сколько человек необходимо разделить счёт?"); | ||
|
|
||
|
|
||
| while (true) { | ||
|
|
||
| if (scanner.hasNextInt()) { | ||
| countPersons = scanner.nextInt(); | ||
|
|
||
| if (countPersons <= 1) { | ||
| System.out.println("Некорректное значение, введите число больше 1"); | ||
| } else { | ||
| break; | ||
| } | ||
| } else { | ||
| System.out.println("Ошибка,нужно ввести целочисленное число"); | ||
|
|
||
| } | ||
| scanner.nextLine(); | ||
|
|
||
| } | ||
|
|
||
| Products products = new Products(); | ||
|
|
||
| products.TotalproductAndPrice(); | ||
|
|
||
|
|
||
| double result=Products.totalPrice/countPersons;//подсчет сколько должен заплатить каждый | ||
|
Ded-Rinat marked this conversation as resolved.
|
||
|
|
||
| Convert convert=new Convert(); | ||
|
Ded-Rinat marked this conversation as resolved.
|
||
|
|
||
| System.out.printf("К оплате с человека: %.2f %s ",result, Convert.convertRub(result)); | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
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,58 @@ | ||
|
|
||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| public class Products { | ||
|
|
||
| double priceProduct;// стоимость товара | ||
| String nameProduct;// наименование товара | ||
| static double totalPrice;// общая сумма | ||
| String listProduct="Добавленные товары:";// список товаров | ||
|
|
||
| Scanner scan = new Scanner(System.in); | ||
|
|
||
|
|
||
| public void TotalproductAndPrice() { | ||
|
Ded-Rinat marked this conversation as resolved.
|
||
|
|
||
| while (true) { | ||
| System.out.println("Введите наименование товара"); | ||
| nameProduct = scan.next(); | ||
| System.out.println("Товар добавлен в калькулятор"); | ||
| listProduct += "\n"+nameProduct; | ||
|
|
||
| System.out.println("Введите стоимость товара в формате рубли,копейки"); | ||
| while (true) { | ||
| if (scan.hasNextDouble()) { | ||
| priceProduct = scan.nextDouble(); | ||
|
|
||
| if (priceProduct <= 0) { | ||
| System.out.println("Стоимость д.б. больше 0, повторите ввод"); | ||
|
|
||
| } else { | ||
| break; | ||
| } | ||
|
|
||
| } else { | ||
| System.out.println("Введите корректное значение в цифрах"); | ||
| scan.next(); | ||
| } | ||
| } | ||
| scan.nextLine(); | ||
| totalPrice += priceProduct; | ||
| System.out.println("Желаете добавить еще товар? Если нет, то напишите \"завершить\""); | ||
| String input = scan.nextLine(); | ||
| if (input.equalsIgnoreCase("завершить")) { | ||
| break; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| System.out.println(listProduct); | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.