Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EasterCozonacs {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double budget = Double.parseDouble(scan.nextLine());
- double priceOfKiloFlour = Double.parseDouble(scan.nextLine());
- double priceOfPackEggs = 0.75 * priceOfKiloFlour;
- double priceOfLiterMilk = priceOfKiloFlour + (0.25 * priceOfKiloFlour);
- int countCozunac = 0;
- int countColouredEggs = 0;
- double pricePerOneCozunac = priceOfKiloFlour + priceOfPackEggs + (priceOfLiterMilk/4.0);
- while (budget > pricePerOneCozunac){
- countCozunac ++;
- budget -= pricePerOneCozunac;
- countColouredEggs += 3;
- if(countCozunac % 3 == 0){
- countColouredEggs -= countCozunac - 2;
- }
- }
- System.out.printf("You made %d cozonacs! Now you have %d eggs and %.2fBGN left.", countCozunac, countColouredEggs, budget);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement