Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. package MidExam1604;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Problem1 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double bugdet = Double.parseDouble(scanner.nextLine());
  10.  
  11. double flourPricePerKg = Double.parseDouble(scanner.nextLine());
  12. double milkPricePerL = flourPricePerKg * 1.25;
  13. double eggsPricePerPack = flourPricePerKg * 0.75;
  14.  
  15.  
  16. double pricePerCozonac = flourPricePerKg + eggsPricePerPack + (milkPricePerL / 4);
  17. int cozonacs = 0;
  18. int coloredEggs = 0;
  19.  
  20. while (bugdet-pricePerCozonac > 0) {
  21.  
  22. bugdet -= (flourPricePerKg + eggsPricePerPack + (milkPricePerL / 4));
  23.  
  24. cozonacs++;
  25. coloredEggs += 3;
  26.  
  27. if (cozonacs != 0 && cozonacs % 3 == 0) {
  28. coloredEggs -= cozonacs - 2;
  29. }
  30. }
  31.  
  32. System.out.printf("You made %d cozonacs! Now you have %d eggs and %.2fBGN left.", cozonacs, coloredEggs, bugdet);
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement