A cookie recipe calls for the following ingredients:
1.5 cups of sugar
1 cup of butter
2.75 cups of flour
The recipe produces 48 cookies with this amount of the ingredients. Write a program that asks the user how many cookies he or she wants to make, and then displays the number of cups of each ingredient needed for the specified number of cookies.
In Java code please.
import java.util.Scanner; public class Cookies { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int n; System.out.print("Enter number of cookies: ");; n = scanner.nextInt(); System.out.println("Sugar = "+(n/48.0)*2+" cup(s)"); System.out.println("Butter = "+(n/48.0)+" cup(s)"); System.out.println("Flour = "+(n/48.0)*3+" cup(s)"); } }
Get Answers For Free
Most questions answered within 1 hours.