Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_17_January_2016 - created by borkins on 2017-05-01.
- */
- import java.util.Scanner;
- public class _01_CakeTycoon
- {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- int cakesWanted = Integer.parseInt(scan.nextLine());
- double kgFlourForCake = Double.parseDouble(scan.nextLine());
- int kgFlourAvailable = Integer.parseInt(scan.nextLine());
- int trufflesAvailable = Integer.parseInt(scan.nextLine());
- int trufflesPrice = Integer.parseInt(scan.nextLine());
- int cakesCanProduce = (int) (kgFlourAvailable / kgFlourForCake);
- if (cakesCanProduce < cakesWanted)
- {
- double kgFlourDeficit = ((double) kgFlourForCake * cakesWanted) - kgFlourAvailable;
- System.out.printf("Can make only %d cakes, need %.2f kg more flour", cakesCanProduce, kgFlourDeficit);
- }
- else {
- long trufflesCost = (long) trufflesAvailable * trufflesPrice;
- double cakePrice = (double) trufflesCost / cakesWanted * 1.25;
- System.out.printf("All products available, price of a cake: %.2f", cakePrice);
- }
- }
- }
Add Comment
Please, Sign In to add comment