Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MidExam1604;
- import java.util.Scanner;
- public class Problem1 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double bugdet = Double.parseDouble(scanner.nextLine());
- double flourPricePerKg = Double.parseDouble(scanner.nextLine());
- double milkPricePerL = flourPricePerKg * 1.25;
- double eggsPricePerPack = flourPricePerKg * 0.75;
- double pricePerCozonac = flourPricePerKg + eggsPricePerPack + (milkPricePerL / 4);
- int cozonacs = 0;
- int coloredEggs = 0;
- while (bugdet-pricePerCozonac > 0) {
- bugdet -= (flourPricePerKg + eggsPricePerPack + (milkPricePerL / 4));
- cozonacs++;
- coloredEggs += 3;
- if (cozonacs != 0 && cozonacs % 3 == 0) {
- coloredEggs -= cozonacs - 2;
- }
- }
- System.out.printf("You made %d cozonacs! Now you have %d eggs and %.2fBGN left.", cozonacs, coloredEggs, bugdet);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement