Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Problem06 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int countOfBakers = Integer.parseInt(scan.nextLine());
- double moneyGain = 0.0;
- int totalCnt = 0;
- for (int i = 0; i < countOfBakers; i++) {
- int cookiesCnt = 0;
- int cakesCnt = 0;
- int wafflesCnt = 0;
- String bakerName = scan.nextLine();
- String sweetType = scan.nextLine();
- while (!sweetType.equals("Stop baking!")) {
- int sweetsCnt = Integer.parseInt(scan.nextLine());
- totalCnt += sweetsCnt;
- if (sweetType.equals("cookies")) {
- cookiesCnt += sweetsCnt;
- moneyGain += sweetsCnt * 1.50;
- } else if (sweetType.equals("cakes")) {
- cakesCnt += sweetsCnt;
- moneyGain += sweetsCnt * 7.80;
- } else if (sweetType.equals("waffles")) {
- wafflesCnt += sweetsCnt;
- moneyGain += sweetsCnt * 2.30;
- }
- sweetType = scan.nextLine();
- }
- System.out.printf("%s baked %d cookies, %d cakes and %d waffles.%n",
- bakerName, cookiesCnt, cakesCnt, wafflesCnt);
- }
- System.out.printf("All bakery sold: %d%n", totalCnt);
- System.out.printf("Total sum for charity: %.2f lv.", moneyGain);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement