Repository navigation
Recreate new Pull Request #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
Paffnuty
wants to merge
8
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
8 commits
Select commit
Hold shift + click to select a range
e6fb7da
Add dev branch
3bbf786
Fist steps draft
Paffnuty 38255aa
Final version 1.0
Paffnuty 3498a70
Release 1.1
Paffnuty bbbf208
Release 1.2
Paffnuty bce918b
Release 1.2.1
Paffnuty 72c9e6e
release 1.3
Paffnuty 48825ec
release 1.3
Paffnuty 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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| import java.util.Scanner; | ||
| public class Calculator { | ||
|
|
||
| String itemNameList = ""; | ||
| int numItems; | ||
| float price; | ||
|
|
||
|
|
||
| Calculator (String itemNameList, float price, int numItems ) { | ||
| this.itemNameList = itemNameList; | ||
| this.price = price; | ||
| this.numItems = numItems; | ||
| } | ||
|
|
||
| } |
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,52 @@ | ||
| // dev branch for Y.Practicum | ||
|
|
||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
|
|
||
| public static void main(String[] args) { | ||
| // ваш код начнется здесь | ||
| // вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости | ||
| System.out.println("Привет Мир"); | ||
|
|
||
| Scanner scanner = new Scanner(System.in); | ||
| Calculator calcPersonBill = new Calculator("", 0, 0); | ||
| checkAndFormat checker = new checkAndFormat(); | ||
| //System.out.println("Привет мир!!!"); | ||
| System.out.println("На сколько человек желаете разделить счёт?"); | ||
|
|
||
| // проверка ввода на тип int | ||
| int numPerson = checker.checkPersonVal(); | ||
|
|
||
| while (true) { | ||
| System.out.println("Введите Название товара"); | ||
|
|
||
| calcPersonBill.itemNameList = calcPersonBill.itemNameList + "\n" + scanner.nextLine(); // добавляем имя в строку | ||
|
|
||
| System.out.println("Введите цену товара"); | ||
|
|
||
| calcPersonBill.price = calcPersonBill.price + checker.checkItemVal(); // Складываем полученые цены по мере ввода | ||
| //scanner.nextLine(); // специфичный метод для завершения ввода... | ||
|
|
||
| System.out.println("Товар добавлен"); | ||
| System.out.println("Еще добавим?"); | ||
|
|
||
| if ((scanner.nextLine()).equalsIgnoreCase("Завершить")) { // проверка если пользователь завершил ввод | ||
| break; | ||
| } else calcPersonBill.numItems++; | ||
| } | ||
| float eachPrice = calcPersonBill.price/numPerson; | ||
|
|
||
| System.out.print("Добавленные товары:"); | ||
| System.out.println(calcPersonBill.itemNameList); | ||
| System.out.println(" "); | ||
|
|
||
| //String totalSum = "Общая сумма товаров: %.2f"; | ||
| System.out.print("Общая сумма товаров: "); | ||
| checker.moneyUnitformat(calcPersonBill.price); // печать суммы товаров правильным с окончанием рублей | ||
|
|
||
| System.out.print("Сумма к оплате с человека: "); | ||
| checker.moneyUnitformat(eachPrice); // печать Сумма к оплате с человека правильным с окончанием рублей | ||
|
|
||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
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,77 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class checkAndFormat { | ||
|
|
||
|
|
||
| // Обработка слова Рубль и вывод на печать | ||
| public static void moneyUnitformat(float Munit) { | ||
| String money = ""; | ||
| //String totalSum = "Общая сумма товаров: %.2f"; | ||
|
|
||
| int iMunit = (int) Munit; | ||
| int mCh = iMunit % 10; | ||
|
|
||
| if (iMunit % 100 >= 11 && iMunit <= 14) { | ||
| money = "%.2f рублей"; | ||
| System.out.println(String.format(money, Munit)); | ||
| } else { | ||
| switch (mCh) { | ||
| case 1: | ||
| money = "%.2f рубль"; | ||
| System.out.println(String.format(money, Munit)); | ||
| break; | ||
| case 2: | ||
| case 3: | ||
| case 4: | ||
| money = "%.2f рубля"; | ||
| System.out.println(String.format(money, Munit)); | ||
| break; | ||
| default: | ||
| money = "%.2f рублей"; | ||
| System.out.println(String.format(money, Munit)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // функция проверки корректности ввода количества человек и далее вывода в main | ||
| public static int checkPersonVal() { | ||
| Scanner scanner = new Scanner(System.in); | ||
| int numPerson; | ||
| while (true) { | ||
|
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. |
||
| if (!scanner.hasNextInt()) { | ||
| System.out.println("Извините, но это явно не число. Введите число и попробуйте снова!"); | ||
| scanner.nextLine(); | ||
| } else { | ||
| numPerson = scanner.nextInt(); | ||
| scanner.nextLine(); | ||
| if (numPerson >= 1) { | ||
| break;} | ||
| else {System.out.println("Значение не подходит, введите другое значение"); | ||
| scanner.nextLine();} | ||
| } | ||
| } | ||
| return numPerson; | ||
| } | ||
|
|
||
|
|
||
| // функция проверки корректности ввода цены товара и далее вывода в main | ||
| public static float checkItemVal() { | ||
| Scanner scanner = new Scanner(System.in); | ||
| float Item; | ||
| while (true) { | ||
| if (!scanner.hasNextFloat()) { | ||
| System.out.println("Извините, но это явно не число. Введите число и попробуйте снова!"); | ||
| scanner.nextLine(); | ||
| }else{ | ||
| Item = scanner.nextFloat(); | ||
| scanner.nextLine(); // специфичный метод для завершения ввода... | ||
| if (Item > 0) { | ||
| break;} | ||
| else {System.out.println("Значение не подходит, введите другое значение"); | ||
| scanner.nextLine();;} | ||
| } | ||
| } | ||
| return Item; | ||
| } | ||
|
|
||
| } | ||
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.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⏫ Обычно классы принято называть с большой буквы