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 bakers = Integer.parseInt(scanner.nextLine()),
- totalSweets = 0;
- String command;
- double totalSum = 0;
- for (int i = 0; i < bakers; i++) {
- String baker = "", sweet = "";
- int cookies = 0, cakes = 0, waffles = 0, sweetCount;
- while (!(command = scanner.nextLine()).equals("Stop baking!")) {
- if (baker.isEmpty()) {
- baker = command;
- } else {
- sweet = command;
- sweetCount = Integer.parseInt(scanner.nextLine());
- if (sweet.equals("cookies")) {
- cookies += sweetCount;
- } else if (sweet.equals("cakes")) {
- cakes += sweetCount;
- } else {
- waffles += sweetCount;
- }
- totalSweets += sweetCount;
- }
- }
- totalSum += 1.50 * cookies + 7.80 * cakes + 2.30 * waffles;
- System.out.printf("%s baked %d cookies, %d cakes and %d waffles.\n", baker, cookies, cakes, waffles);
- }
- System.out.printf("All bakery sold: %d\nTotal sum for charity: %.2f lv.\n", totalSweets, totalSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement