Advertisement
Spocoman

Easter Decoration

Sep 4th, 2024
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int clients = Integer.parseInt(scanner.nextLine()), counter;
  7.         double sum, totalSum = 0;
  8.         String stock;
  9.  
  10.         for (int i = 0; i < clients; i++) {
  11.             counter = 0;
  12.             sum = 0;
  13.             while (!(stock = scanner.nextLine()).equals("Finish")) {
  14.                 switch (stock) {
  15.                     case "basket" -> sum += 1.50;
  16.                     case "wreath" -> sum += 3.80;
  17.                     case "chocolate bunny" -> sum += 7.00;
  18.                 }
  19.                 counter++;
  20.             }
  21.  
  22.             if (counter % 2 == 0) {
  23.                 sum *= 0.80;
  24.             }
  25.  
  26.             totalSum += sum;
  27.             System.out.printf("You purchased %d items for %.2f leva.\n", counter, sum);
  28.         }
  29.         System.out.printf("Average bill per client is: %.2f leva.\n", totalSum / clients);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement