Question: Answer in Python 3 Answer in Python Purpose: Practice with getting data from functions. Some basic numerical problem-solving Degree of Difficulty: Moderate At the local

Answer in Python 3Answer in Python 3 Answer in Python Purpose: Practice with getting datafrom functions. Some basic numerical problem-solving Degree of Difficulty: Moderate At the

Answer in Python

Purpose: Practice with getting data from functions. Some basic numerical problem-solving Degree of Difficulty: Moderate At the local supermarket, hotdogs are sold in packages containing a dozen (12) hotdogs, and yet infuriat- ingly, hotdog buns are sold in packages containing 8 buns. One question we can ask is this given some number of packages of dogs and buns, how many hotdogs can we make lone dog per bun)? In this prob- lem, you'll answer that question. Before we get started, let's resolve some ambiguity. A hotdog can mean the sausage alone, or the sandwich you get when you combine a sausage and a bun. So, from now on, we'll call the sausage a "frank', a hotdog bun will be called a "bun' and the complete sandwich is called a "hotdog'. Got it? Here is a description of WHAT your program should do when it's finished: Pressing the 'f key/g' key increases/decreases the number of frank packages purchased by one. Make sure not to let the number of frank packages become negative (hint you can use the max() function to do this). Pressing the 'b' key/"n" key increases/decreases the number of bun packages purchased by one. Again, no negatives Display the current number of frank packages, current number of bun packages, and the current number of hotdogs you can make one frank per bun) Some examples If you have 2 packages of franks (24 franks total), and 3 packages of buns (24 buns total, you can make 24 complete hotdogs, and there will be no extra buns or franks. If you have 1 package of franks (12 franks), and 2 packages of buns (16 buns), you can make 12 com- plete hotdogs, and you will have 4 extra buns. - If you have 2 packages of franks (24 franks) and 2 packages of buns (16 buns) you can make 16 com- plete hotdogs, and there will be 8 extra franks. Now, here is a description of HOW you should write the program: Start by understanding the problem: . Read the question carefully, and identify the things you are sure about, and the things you are unsure about. If you have any questions, make sure to ask an instructor, a TA or post on the class discussion forums Next, prepare some test cases. A test case is a set of input values for the program where you will be able to compare the result your program gives you with the result that you are expecting (because you calculated it by hand). Prepare six examples to demonstrate that your program works, as follows: . Two different examples where there is nothing left over - Two different examples where there are franks left over, but no buns. - Two different examples where there are buns left over, but no franks. For this problem, you will need to hand in your testing in a separate document. This can be a simple text document if you like, where for each of the 6 test cases, you state something like: 'l used A packages of franks and B packages of buns. This should yield a result of X total hotdogs. My program gave a result of Y total hotdogs". Of course, if your program is working, X and Y will be the same, but the whole point of testing is not to assume that will be the case in advance! Next, start writing your code by creating a function called make_hotdogs (). This function should accept two parameters, the number of packages of franks and the number of packages of buns, and should follow these steps: Calculate how many franks and buns there are based on the number of packages of each Calculate how many complete hotdogs can be made (one frank per bun) Return the number of complete hotdogs you can make Once this function is done, you can (and should!) test it before adding any further components of the program. You can do this by just writing a few function calls with hard-coded, literal arguments and just printing out the return value. You don't need to hand in this intermediate testing, but it's a good habit to get into and will save you time in the long run! Finally, add the interactive components to the program. This will include handling the keyboard input to modify the number of packages of franks and buns, as well as displaying the program's output to the Processing canvas. Here's how the program might look like while it is running packages of franks 2 packages of banesi 3 hodogs made 24 Figure 2: Simple interface displaying the number of hot dogs that can be made What To Hand In: Your Processing sketch folder compressed as a zip file named a5q2.zip. This folder should contain your Processing program named a5q2.pyde and a sketch.properties project file. Also in- clude a document named a5q2_testing.txt or else .pdf or .rtf) with your six examples and the solutions (include the number of franks packages, number of buns packages, expected result, and actual result given by the program)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!