The question in the textbook is as follows:
Hot Dog Cookout Calculator
Assume that hot dogs come in packages of 10, and hot dog buns come in packages of 8. Design a modular program that calculates the number of packages of hot dogs and the number of packages of hot dog buns needed for a cookout, with the minimum amount of leftovers. The program should ask the user for the number of people attending the cookout, and the number of hot dogs each person will be given. The program should display the following:
The minimum number of packages of hot dogs required
The minimum number of packages of buns required
The number of hot dogs that will be left over
The number of buns that will be left over
This is the python code I have for the unmodularized version. I figured if I could figure out the unmodularized version I could convert it to modularized, but unfortunately I am stuck.on how to proceed further.
This is the python code I have so far.
num_of_pkg_of_dogs = 0
num_of_pkg_of_buns = 0
dogs_per_pkg = 10
buns_per_pkg = 8
leftover_dogs = 0
leftover_buns = 0
total_num_dogs = 0
total_num_buns = 0
num_attending_cookout = 0
num_of_dogs_pp = 0
pkg_of_dogs_needed = 0
pkg_of_buns_needed = 0
num_attending_cookout = int(input("Enter number of people attending cookout: "))
num_of_dogs_pp = int(input("Enter number of Hot Dogs per person: "))
total_num_dogs = num_attending_cookout*num_of_dogs_pp
total_num_buns = num_attending_cookout*num_of_dogs_pp
print("Total number of hot dogs needed: ", total_num_dogs)
print("Total number of buns needed: ", total_num_buns)
pkg_of_dogs_needed = total_num_dogs/dogs_per_pkg
pkg_of_buns_needed = total_num_buns/buns_per_pkg
print("Packages of hot dogs needed: ", pkg_of_dogs_needed)
print("Packages of buns needed: ", pkg_of_buns_needed)
I have divided the code into 4 modules, namely
main.py
info.py
calculation.py
requirements.py
_______________________________________________
info.py
CODE:
#this module takes the input information from the user
total_num_dogs = 0
total_num_buns = 0#initializing the variables
num_attending_cookout = 0
num_of_dogs_pp = 0
num_attending_cookout = int(input("Enter number of people attending cookout: ")) #asking the user the number of people for cookout
num_of_dogs_pp = int(input("Enter number of Hot Dogs per person: ")) #asking the user for the number of hot dogs per person ot be made
total_num_dogs = num_attending_cookout*num_of_dogs_pp #calculating the number of dogs needed
total_num_buns = num_attending_cookout*num_of_dogs_pp #calculating the number of buns needed
_______________________________________________
requirement.py
CODE:
#this module is used to calculate the amount of packages needed import info #calling the info module for the gathered info ot be available in this module import math #math funciton pkg_of_dogs_needed = 0 pkg_of_buns_needed = 0#initializing the variables dogs_per_pkg = 10 buns_per_pkg = 8 pkg_of_dogs_needed = math.ceil(info.total_num_dogs/dogs_per_pkg) #calculating the number of package of dogs needed and using the ceil funciton to get a valid integer number of package pkg_of_buns_needed = math.ceil(info.total_num_buns/buns_per_pkg) #calculating the number of package of buns needed and using the ceil funciton to get a valid integer number of package
___________________________________________
calculation.py
CODE:
#this module will calculate the amount of leftovers import requirement import info leftover_dogs = 0 leftover_buns = 0 leftover_dogs = requirement.pkg_of_dogs_needed*requirement.dogs_per_pkg - info.total_num_dogs #leftover dogs is the difference between the required number of dogs to the available number of dogs in the package leftover_buns = requirement.pkg_of_buns_needed*requirement.buns_per_pkg - info.total_num_buns #leftover buns is the difference between the required number of buns to the available number of buns in the package
___________________________________________________________
main.py
CODE:
#This is the main module where all the informations will be displayed and other modules will be called
import info #calling all the modules
import requirement
import calculation
print("Total number of hot dogs needed: ", info.total_num_dogs) #printing all the values gathered from various modules
print("Total number of buns needed: ", info.total_num_buns)
print("Packages of hot dogs needed: ", requirement.pkg_of_dogs_needed)
print("Packages of buns needed: ", requirement.pkg_of_buns_needed)
print("Number of dogs left: ",calculation.leftover_dogs)
print("Number of buns left: ",calculation.leftover_buns)
Code images:
main.py

info.py

requirement.py

calculation.py
______________________________________
OUTPUT:
Thank You!
The question in the textbook is as follows: Hot Dog Cookout Calculator Assume that hot dogs...
Hello: Need help with this program. In JavaScript please // Assume hot dogs come in packages of 10, and hot dog buns come in packages of 8. // Write a program that calculates the number of packages of hot dogs and the // number of packages of hot dog buns needed for a cookout, with the minimum amount // of leftovers. The program should ask the user for the number of people attending // the cookout. Assume each person will...
In python coding please with proper indentation, comments, good variable initializations, questions asking for the parameters of the code and output display with explanation.: Assume that hot dogs come in packages of 20, and hot dog buns come in packages of 8. Design a modular program that calculates the number of packages of hot dogs and the number of packages of hot dog buns needed for a cookout, with the minimum amount of leftovers. The program should ask the user...
In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...
Propose: In this lab, you will complete a Python program with one partner. This lab will help you with the practice modularizing a Python program. Instructions (Ask for guidance if necessary): To speed up the process, follow these steps. Download the ###_###lastnamelab4.py onto your desktop (use your class codes for ### and your last name) Launch Pyscripter and open the .py file from within Pyscripter. The code is already included in a form without any functions. Look it over carefully....
For this assignment, suppose that a fence is recording entry and exit into the park via a string as the gate swings open and folks walk in or out with their pet. For example, C++ DP+dp+CP+cp would indicate that an adult dog and an adult entered the park, then a puppy and child entered the park, then an adult cat and an adult entered the park and finally a kitten and a child entered the park. From this information, note...
Suppose the corridor in which you live has n tiles in a row from one end to the other. There is a lot of junk strewn in the corridor. E.g Suppose the corridor has only 5 tiles, and the junk consists of a solitary shoe on Tile 2 and a chips packet and a piece of paper on Tile 5. The junk may be represented in array form as [0, 1, 0, 0, 2], where each array element a[i] represents...
Please answer this question using python programming only and provide a screen short for this code. Homework 3 - Multiples not less than a number Question 1 (out of 3) This homework is a SOLO assignment. While generally I encourage you to help one another to learn the material, you may only submit code that you have composed and that you understand. Use this template to write a Python 3 program that calculates the nearest multiple of a number that...
c++ question, i put the txt attachment picture for this
question... please include comments on calculations and
varibles
Description In this program, you will write a program to emulate a vending machine (somewhat). In this version of the program, you will use a struct type defined below struct snackType string name; string code; double price; int remaining; Where name contains the snack's name, code contains the 2 digit code for the item, price holds the item's price, and remaining holds...
If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...
Chapter 8
Python Case study Baseball Team Manager
For this case study,
you’ll use the programming skills that you learn in Murach’s
Python Programming to develop a program that helps a
person manage a baseball team. This program stores the data for
each player on the team, and it also lets the manager set a
starting lineup for each game. After you read chapter 2, you can
develop a simple program that calculates the batting average for a
player. Then,...