程序代写代做代考 Programming Exercise 2-10

Programming Exercise 2-10

# Variables for the number of cookies,

# cups of sugar, butter, and flour.

cookies = 0.0

sugar = 0.0

butter = 0.0

flour = 0.0

# Constants for the number of cookies, cups

# of sugar, butter, and flour in the original recipe.

COOKIES_RECIPE = 48.0

SUGAR_RECIPE = 1.5

BUTTER_RECIPE = 1.0

FLOUR_RECIPE = 2.75

# Get the number of cookies.

cookies = float(input(“Enter the number of cookies: “))

# Calculate the cups of sugar needed to make the cookies.

sugar = (cookies * SUGAR_RECIPE) / COOKIES_RECIPE

# Calculate the cups of butter needed to make the cookies.

butter = (cookies * BUTTER_RECIPE) / COOKIES_RECIPE

# Calculate the cups of flour needed to make the cookies.

flour = (cookies * FLOUR_RECIPE) / COOKIES_RECIPE

# Print the amount of butter, sugar, and flour needed

# to make the specified number of cookies.

print (“To make”, cookies, “cookies, you will need:”)

print (format(sugar, ‘.2f’), “cups of sugar”)

print (format(butter, ‘.2f’), “cups of butter”)

print (format(flour, ‘.2f’), “cups of flour”)

Declare Real cookies,

sugar, butter, flour

Start

Constant Real

COOKIES_RECIPE =

48.0

Constant Real

SUGAR_RECIPE = 1.5

Constant Real

BUTTER_RECIPE = 1.0

Constant Real

FLOUR_RECIPE = 2.75

Display “Enter

the number of

cookies.”

Input cookies

A

A

sugar = (cookies *

SUGAR_RECIPE) /

COOKIES_RECIPE

butter = (cookies *

BUTTER_RECIPE) /

COOKIES_RECIPE

flour = (cookies *

FLOUR_RECIPE) /

COOKIES_RECIPE

Display “To

make”, cookies,

“cookies, you

will need:”

Display sugar,

“cups of sugar.”

B

B

Display butter,

“cups of butter.”

Display flour,

“cups of flour.”

End