Repository navigation
Проектная работа №1 (v. "Быдло 1.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
Forquad
wants to merge
3
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
3 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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| public class CorrectRub { | ||
| static String getFormatRub() { | ||
|
|
||
| double personalCost = Main.sum/Main.quantity; | ||
| String correctRub = ""; | ||
| if ((Math.floor(personalCost)%100) >= 11 && (Math.floor(personalCost)%100) <= 14) { | ||
| correctRub = "рублей"; | ||
| } else { | ||
| if ((Math.floor(personalCost) % 10) == 1) { | ||
| correctRub = "рубль"; | ||
| } else if ((Math.floor(personalCost) % 10) > 1 && (Math.floor(personalCost) % 10) < 5) { | ||
| correctRub = "рубля"; | ||
| } else { | ||
| correctRub = "рублей"; | ||
| } | ||
| } | ||
| return correctRub; | ||
| } | ||
| } | ||
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,57 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
| static Scanner scanner = new Scanner(System.in); //Добавляем сканер длядальнейшего использования в методах. | ||
| static String items = ""; | ||
| static double sum = 0; | ||
|
|
||
| static int quantity=0; | ||
|
|
||
| public static void main(String[] args) { | ||
| // ваш код начнется здесь | ||
| // вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости | ||
| System.out.println("Привет Мир"); | ||
|
|
||
| int numberOfPeople = People.howMuchPeople(); | ||
| whatInBill(); | ||
| double personalCost = sum/numberOfPeople; | ||
| String rub = CorrectRub.getFormatRub(); | ||
| printResult (personalCost, rub); | ||
| } | ||
|
|
||
| public static void whatInBill() { | ||
| StringBuilder builder = new StringBuilder(); | ||
| System.out.println("Ну, и что ели?"); | ||
| while (true) { | ||
| String input = scanner.nextLine(); | ||
| if (input.equalsIgnoreCase("Завершить")) { | ||
| System.out.println("Фух! Я надеюсь вы не лопните..."); | ||
| break; | ||
| } | ||
| builder.append(items+input).append("\n"); | ||
| System.out.println("А сколько стоило?"); | ||
| double price; | ||
| while (true) { | ||
| if (scanner.hasNextDouble()) { | ||
| price = scanner.nextDouble(); | ||
| if (price < 0) { | ||
| System.out.println("Серьезно, покормили и денег дали? Давай еще раз..."); | ||
| } else { | ||
| sum = price + sum;//Считаем стоимость товаров | ||
| System.out.println("Товар добавлен, общая сумма: " + sum + " руб. Что еще добавить из блюд? Если ничего, напиши 'Завершить'"); | ||
| break; | ||
| } | ||
| } else { | ||
| System.out.println("Не шути со мной, кожанный, у тебя последняя попытка"); | ||
| scanner.nextLine(); | ||
| } | ||
| } | ||
| scanner.nextLine(); | ||
| } | ||
| items=builder.toString(); | ||
| } | ||
|
|
||
|
|
||
| static void printResult(double personalCost, String rub) { | ||
| System.out.println("Добавленные товары: "); | ||
| System.out.print(items); | ||
| System.out.printf("Короче, клоуны, с каждого к оплате: %.2f %s", personalCost, 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import java.util.Scanner; | ||
|
|
||
| public class People { | ||
| static Scanner scanner = new Scanner(System.in); | ||
|
|
||
| public static int howMuchPeople() { | ||
| System.out.println("Сколько Вас, ребят?"); | ||
| while (true) { | ||
| if (scanner.hasNextInt()) { | ||
| Main.quantity = scanner.nextInt(); | ||
| if (Main.quantity == 1) { | ||
| System.out.println("Ты что, дурак? Ты ешь один...Попробуй еще раз..."); | ||
| } else if (Main.quantity < 1) { | ||
| System.out.println("Серьезно? Ты пересмотрелл Рикк и Морти? Богатый внутренний мир... попробуй еще раз..."); | ||
| } else if (Main.quantity > 1){ | ||
| break; | ||
| } | ||
| } else { | ||
| System.out.println("О боги!... Вы же не буквы или половинчатые...Кожанный, давай попробуем еще раз..."); | ||
| scanner.next(); | ||
| } | ||
| } | ||
| return Main.quantity; | ||
| } | ||
| } |
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.