grodek118

Ingredient Adjuster

Sep 3rd, 2022
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner keyboard = new Scanner(System.in);
  10.  
  11.         float sugar = 1.5f;
  12.         float butter = 1;
  13.         float flour = 2.75f;
  14.         float sugarNeeded;
  15.         float butterNeeded;
  16.         float flourNeeded;
  17.         float cookies;
  18.  
  19.         System.out.println("How many cookies you want to make?");
  20.         cookies = keyboard.nextFloat();
  21.  
  22.         sugarNeeded = sugar / (48 / cookies);
  23.         butterNeeded = butter / (48 / cookies);
  24.         flourNeeded = flour / (48 / cookies);
  25.  
  26.         System.out.println("You need:" + "\n" + sugarNeeded + " cups of sugar" + "\n" + butterNeeded + " cup of butter" + "\n" + flourNeeded + " cups of flour");
  27.  
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment