Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EasterCozonacs {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. double budget = Double.parseDouble(scan.nextLine());
  7. double priceOfKiloFlour = Double.parseDouble(scan.nextLine());
  8. double priceOfPackEggs = 0.75 * priceOfKiloFlour;
  9. double priceOfLiterMilk = priceOfKiloFlour + (0.25 * priceOfKiloFlour);
  10. int countCozunac = 0;
  11. int countColouredEggs = 0;
  12. double pricePerOneCozunac = priceOfKiloFlour + priceOfPackEggs + (priceOfLiterMilk/4.0);
  13.  
  14. while (budget > pricePerOneCozunac){
  15. countCozunac ++;
  16. budget -= pricePerOneCozunac;
  17. countColouredEggs += 3;
  18.  
  19. if(countCozunac % 3 == 0){
  20. countColouredEggs -= countCozunac - 2;
  21. }
  22.  
  23. }
  24.  
  25. System.out.printf("You made %d cozonacs! Now you have %d eggs and %.2fBGN left.", countCozunac, countColouredEggs, budget);
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement