Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: Python What I have so far: package_buns = 2 package_franks = 3 num_hotdogs = def setup(): size(500, 500) def draw(): background(0) global package_buns,

Language: Python

image text in transcribedimage text in transcribed

What I have so far:

package_buns = 2 package_franks = 3

num_hotdogs = ""

def setup(): size(500, 500) def draw(): background(0) global package_buns, package_franks, num_hotdogs text("Package(s) of buns: ", 50, 50) text(package_buns, 175, 50) text("Package(s) of franks: ", 50, 100) text(package_franks, 175, 100) text("The number of hotdogs possible: ", 50, 150) text(num_hotdogs, 250, 150) def keyPressed(): global package_buns, package_franks, num_hotdogs if key == "f" or key == "b": package_buns = package_buns+1 package_franks = package_franks+1 elif key == "g" or key == "n": package_buns = max(package_buns-1, 2) package_franks = max(package_franks-1, 3) if key == "x": num_hotdogs = package_buns*8 / package_franks*12

At the local supermarket, hotdogs are sold in packages containing a dozen (12) hotdogs, and yet 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 (one dog per bun)? In this problem, 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 . Pressing the 'b' key/"n' key increases/decreases the number of bun packages purchased by one 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 tota), and 3 packages of buns (24 buns tota), you can . If you have 1 package of franks (12 franks), and 2 packages of buns (16 buns), you can make 12 com . If you have 2 packages of franks (24 franks) and 2 packages of buns (16 buns) you can make 16 com make 24 complete hotdogs, and there will be no extra buns or franks. plete hotdogs, and you will have 4 extra buns. 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 youu 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 "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

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions