Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EasterDecoration {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numberClients = Integer.parseInt(scanner.nextLine());
- int totalItems = 0;
- double totalAmountSpent = 0;
- for (int i = 0; i < numberClients; i++) {
- double amountSpentByClient = 0;
- int numberItemsByClient = 0;
- String command = scanner.nextLine();
- while (!"Finish".equals(command)) {
- if ("basket".equals(command)) {
- amountSpentByClient += 1.50;
- numberItemsByClient++;
- } else if ("wreath".equals(command)) {
- amountSpentByClient += 3.80;
- numberItemsByClient++;
- } else if ("chocolate bunny".equals(command)) {
- amountSpentByClient += 7;
- numberItemsByClient++;
- }
- command = scanner.nextLine();
- }
- if (numberItemsByClient % 2 == 0) {
- amountSpentByClient *= 0.8;
- }
- totalAmountSpent += amountSpentByClient;
- System.out.printf("You purchased %d items for %.2f leva.\n", numberItemsByClient, amountSpentByClient);
- }
- double avg = totalAmountSpent / numberClients;
- System.out.printf("Average bill per client is: %.2f leva.", avg);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement