Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I'm looking for how I could go about doing this problem. I'm new to Chegg, but saw that there was assistance for other assignments

image text in transcribed

Hello, I'm looking for how I could go about doing this problem. I'm new to Chegg, but saw that there was assistance for other assignments that we have had.

Edit: This program is in Python.

Also: image text in transcribed

Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size The first inputs to the program will be the recipe itself. Here is an example recipe that comes from the story "Chitty Chitty Bang Bang", written by lan Fleming, who is much better known for introducing the world to James Bond This is a recipe scaler for serving large crowds! Enter one ingredient per line, with a numeric value first. Indicate the end of input with an empty line 4 tbsp cocoa 1/4 pound butter 2 tsp corn syrup 1 can evaporated milk 1 tsp water Here is the recipe that has been recorded 4 tbsp 1/4 pound butter 2 tsp cocoa corn syrup evaporated milk water can 1tsp How many does this recipe serve? 16 How many people must be served? 25 Multiplying the recipe by 2 8 tbsp 2/4 pound butter 4 tsp 2 can 2 tsp cocoa corn syrup evaporated milk water Serves 32 NOTE: The recipe rounds upwards, since it is usually not practical to obtain fractional cans or tractional eggs, etc. A Couple Free Program Tricks Attractive user-friendly output is rather straightforward, with the help of Python's string formatting features. User- friendly input is a little trickier, so here is a peek at a little of the instructor's code: First trick: The name of an ingredient might be more than one word. This will place all of the extra words into a single string variable 'item': quant, unit, item-line . split(' ',2) # off at most 2 words from the front Second trick: Sometimes the measure will be fractional. We can tell that if there is a slash in there. Not having a slash can be treated the same way as a fraction with a denominator of 1. if '/' in quant: numer, slash, denom-quant.partitionC' # get the parts of the fraction The rest is left up to the student -- since this is a string operation and this fraction represents a number. Extra Credit Option No doubt the output seems to be a little strange to ask for 2/4 pounds of butter. One might think it would be better to ask for 1/2. Modify the program so that all fractions are reduced to their lowest terms. There is a function in the Python math ibrary named gcd that can help with this. Section 2.5 in the on-line text shows how to obtain that. Also, express all improper fractions (where the numerator exceeds the denominator) as mixed fractions. Scaling this recipe by a factor of 10 would ask for 2 1/2 pounds of butter. And of course, the resulting output should still be easy to read

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago