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