Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ExamNovember04BachelorParty {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int sumaGostIzpalnitel = Integer.parseInt(scanner.nextLine());
- double kuvert = 0;
- double prihod = 0;
- int guestsCount = 0;
- double remainingSum = 0;
- String peopleNumberInGroup = scanner.nextLine();
- while (!peopleNumberInGroup.equalsIgnoreCase("The restaurant is full")) {
- int peopleNumber = Integer.parseInt(peopleNumberInGroup);
- if (peopleNumber < 5) {
- kuvert = 100;
- prihod += peopleNumber * kuvert;
- guestsCount += peopleNumber;
- } else {
- kuvert = 70;
- prihod += peopleNumber * kuvert;
- guestsCount += peopleNumber;
- }
- peopleNumberInGroup = scanner.nextLine();
- if (peopleNumberInGroup.equalsIgnoreCase("The restaurant is full")) {
- break;
- }
- }
- remainingSum = Math.round(prihod - sumaGostIzpalnitel);
- if (prihod >= sumaGostIzpalnitel) {
- System.out.printf("You have %d guests and %.0f leva left.", guestsCount, remainingSum);
- } else {
- System.out.printf("You have %d guests and %.0f leva income, but no singer.",
- guestsCount, prihod);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment