Question

A cookie recipe calls for the following ingredients: 1.5 cups of sugar 1 cup of butter...

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.

Homework Answers

Answer #1
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)");
  }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
A cookie recipe calls for the following ingredients: • 1.5 cups of sugar • 1 cup...
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
Stephen is the father of three physically active children, ages 3, 8, and 12 years. He...
Stephen is the father of three physically active children, ages 3, 8, and 12 years. He is concerned about his children’s health because they experience frequent constipation. The favorite family “treat” is homemade oatmeal cookies. Stephen would like to make the cookies higher in fiber and lower in sugar and solid fat than the original recipe. Grandma’s Oatmeal Cookies Ingredients: 1 cup butter, softened 1 cup white granulated sugar 1 cup brown sugar, packed 2 eggs 1 tsp vanilla extract...
Here is a recipe for macaroni and cheese. Ingredients 1 cup elbow macaroni 1 1/2 cups...
Here is a recipe for macaroni and cheese. Ingredients 1 cup elbow macaroni 1 1/2 cups shredded Cheddar cheese 2/3 cup milk 1 egg, beaten 1 tablespoon mustard 1 dash hot pepper sauce Select two ingredients that you feel will make the most significant changes to make this recipe healthier. Name your two ingredients, explain how you are going to make modifications to the two ingredients and discuss the nutrient changes as a result. Remember you are modifying ingredients and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT