223k views
3 votes
Hot Dog Calculator

Hot dogs come 10 to a package and hot dog buns come 8 to a package.
Write a Flowgorithm program that calculates the number of packages of hot dogs
and buns needed for a cookout with minimum leftovers.
The program should ask for the following information:
- Number of people attending the cookout
- Number of hot dogs allocated for each person

The program should calculate and display the following information:
- Minimum packages of hot dogs needed
- Minimum packages of hot dog buns needed
- Number of hot dogs left over
- Number of hot dog buns left over
- Partial packages of hot dogs and buns CANNOT be purchased.

Remember the following:
- Declare all variables and constants
- Initialize all constants
- Comment box for your name, date, and purpose of the program
- Use other comments where appropriate
- DO NOT "hard code numbers" in calculations, use constants
- Use clear prompts for your data input requests
- Clearly label each output number or name
- Modulo operator might be useful

User Moodboom
by
7.8k points

1 Answer

5 votes

Answer:To solve this problem, we need to calculate the number of packages of hot dogs and hot dog buns needed for a cookout with minimum leftovers. Here's a step-by-step explanation of how you can write a Flowgorithm program to solve this:

1. Declare and initialize the constants:

- Constant for the number of hot dogs per package: hotDogsPerPackage = 10

- Constant for the number of hot dog buns per package: bunsPerPackage = 8

2. Declare the variables:

- Variable for the number of people attending the cookout: numPeople

- Variable for the number of hot dogs allocated for each person: hotDogsPerPerson

3. Prompt the user for the number of people attending the cookout:

- Display a clear prompt asking for the number of people attending the cookout.

- Read the input and store it in the numPeople variable.

4. Prompt the user for the number of hot dogs allocated for each person:

- Display a clear prompt asking for the number of hot dogs allocated for each person.

- Read the input and store it in the hotDogsPerPerson variable.

5. Calculate the minimum packages of hot dogs needed:

- Divide the total number of hot dogs required (numPeople * hotDogsPerPerson) by the number of hot dogs per package.

- Round up the result to the nearest whole number using the ceiling function.

- Store the result in a variable called hotDogPackagesNeeded.

6. Calculate the minimum packages of hot dog buns needed:

- Divide the total number of hot dog buns required (numPeople * hotDogsPerPerson) by the number of hot dog buns per package.

- Round up the result to the nearest whole number using the ceiling function.

- Store the result in a variable called bunPackagesNeeded.

7. Calculate the number of hot dogs left over:

- Calculate the total number of hot dogs required (numPeople * hotDogsPerPerson).

- Calculate the total number of hot dogs in the minimum packages needed (hotDogPackagesNeeded * hotDogsPerPackage).

- Subtract the total number of hot dogs in the minimum packages from the total number of hot dogs required.

- Store the result in a variable called hotDogsLeftOver.

8. Calculate the number of hot dog buns left over:

- Calculate the total number of hot dog buns required (numPeople * hotDogsPerPerson).

- Calculate the total number of hot dog buns in the minimum packages needed (bunPackagesNeeded * bunsPerPackage).

- Subtract the total number of hot dog buns in the minimum packages from the total number of hot dog buns required.

- Store the result in a variable called bunsLeftOver.

9. Display the calculated information:

- Display the minimum packages of hot dogs needed.

- Display the minimum packages of hot dog buns needed.

- Display the number of hot dogs left over.

- Display the number of hot dog buns left over.

Remember to include comments throughout your program to explain what each section of code does. Also, make sure to follow the guidelines provided in the question, such as declaring all variables and constants, using clear prompts, and labeling each output number or name.

Step-by-step explanation:

User Ivan Salo
by
7.9k points