Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: A Penny for a Gum Ball Mickey (40 pts) We are going to conduct an experiment in selling gum balls, but we are

image text in transcribed
Part 1: A Penny for a Gum Ball Mickey (40 pts) We are going to conduct an experiment in selling gum balls, but we are going to make a few assumptions. Assume that you are selling gum balls from a vending machine. The machine is a cube, and the gum balls are spheres. You check the machine once a week. The goal is to size the machine so that it is completely full at the start of the week, you never run out of gum balls before you get back to check the machine, and you do not have too many gum balls left at the end of the week to go stale. We will make the assumption that all the gum balls line up so that the number of gum balls Thanks for the Gum Ball! along any dimension of the cube is simply the side length divided by the diameter of the spheres. So if the side length is 9.0 and the gum balls have a radius of 0.5 exactly 9 gum balls would fit along each dimension, or 729 gum balls in total. This is known as a cubic lattice. Do the following: 1. First write two functions, find_volume_sphere (radius) and find_volume_cube (side) that calculate the volume of a sphere given a radius, and that calculate the volume of a cube given a side, respectively. 2. Now ask the user for the radius of the gum balls and the weekly sales. 3. Calculate the total number of gum balls that need to fit in the machine as 1.25 times the weekly sales and use this to calculate the side length of the machine in terms of an integer number of gum balls. Hint: You know the total number of gum balls and in a cubic lattice, you can fit the same mumber along each dimension, so if you can fit N gum balls along each dimension, then the machine holds * gum balls. The math module function ceil will always round up and may be of use here. We won't be cutting gum balls to fit them in the machine.) 4. Calculate a few more values: how many gum balls will actually fit given the dimension you chose (remember that there must be an integer number of gum balls along each dimension of the cube); the volume of the cube; the volume of the gum balls, and the wasted space if we put in both the number of gum balls we need to hold and how many we can hold. 5. Print these values out using the .2f format for all floating point values. Two examples of the program run (how it will look when you run it using Wing IDE 101) are provided in files hw2.part1 output 01.txt and hw2.part1 output_02.txt. (In order to access this file. you will need to download file hw02_files.zip from the Course Materials section of Submitty and unzip it into your directory for HW 2.) We will test your code for the above values as well as a range of different values. Part 1: A Penny for a Gum Ball Mickey (40 pts) We are going to conduct an experiment in selling gum balls, but we are going to make a few assumptions. Assume that you are selling gum balls from a vending machine. The machine is a cube, and the gum balls are spheres. You check the machine once a week. The goal is to size the machine so that it is completely full at the start of the week, you never run out of gum balls before you get back to check the machine, and you do not have too many gum balls left at the end of the week to go stale. We will make the assumption that all the gum balls line up so that the number of gum balls Thanks for the Gum Ball! along any dimension of the cube is simply the side length divided by the diameter of the spheres. So if the side length is 9.0 and the gum balls have a radius of 0.5 exactly 9 gum balls would fit along each dimension, or 729 gum balls in total. This is known as a cubic lattice. Do the following: 1. First write two functions, find_volume_sphere (radius) and find_volume_cube (side) that calculate the volume of a sphere given a radius, and that calculate the volume of a cube given a side, respectively. 2. Now ask the user for the radius of the gum balls and the weekly sales. 3. Calculate the total number of gum balls that need to fit in the machine as 1.25 times the weekly sales and use this to calculate the side length of the machine in terms of an integer number of gum balls. Hint: You know the total number of gum balls and in a cubic lattice, you can fit the same mumber along each dimension, so if you can fit N gum balls along each dimension, then the machine holds * gum balls. The math module function ceil will always round up and may be of use here. We won't be cutting gum balls to fit them in the machine.) 4. Calculate a few more values: how many gum balls will actually fit given the dimension you chose (remember that there must be an integer number of gum balls along each dimension of the cube); the volume of the cube; the volume of the gum balls, and the wasted space if we put in both the number of gum balls we need to hold and how many we can hold. 5. Print these values out using the .2f format for all floating point values. Two examples of the program run (how it will look when you run it using Wing IDE 101) are provided in files hw2.part1 output 01.txt and hw2.part1 output_02.txt. (In order to access this file. you will need to download file hw02_files.zip from the Course Materials section of Submitty and unzip it into your directory for HW 2.) We will test your code for the above values as well as a range of different values

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

Students also viewed these Databases questions

Question

Question in Computer Science Please Write Correct answer 7 .

Answered: 1 week ago