COMP1200-C – Assign 05 solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

Submit assign05.c via Canvas
Before you start writing your program: Download the balloonValues.txt data file from the Assign05 Announcement and save in your COMP1200/assign05 folder. If you do not have folders set up for your assignment files, this is a good time to start. Your assign05.c will look in the folder where it is saved for the data file. A development plan is a process that guides you through solving a problem and creating an algorithm. Create your own algorithm and use it as comments throughout your program. Use section comments to group your statements as well as comments from your algorithm.
Problem: Program: assign04.c On a hot Saturday afternoon, you and your friends notice an empty baby swimming pool on the lawn of your apartment complex. So, why not see if you can fill it with water from water balloons thrown from your second floor balcony.
You will find out how many balloons it takes to fill the pool. To process a large number of balloon throws, you will run your program in batch-mode by reading the values needed to compute the distance each balloon travels as well as the diameter of each balloon from the balloonValues.txt data file. The file columns are theta, velocity, thrower’s height, and diameter. The balloon diameter determines the amount of water in each balloon.
You will calculate the distance a water balloon will travel given the balloon launch angle (theta) in degrees, balloon launch velocity (v) in min/sec, and thrower’s height in feet. Note that the height y0 is the sum of the balcony height and thrower’s height.
You will continue “throwing” balloons while the end of the file has not been reached. After ALL the data in the file has been read, your program should display – the total number of balloons thrown – the number of balloons that hit the pool – the percent of hits – the number of the balloon that caused the pool water to reach capacity – a message saying how many gallons spilled over the edge of the pool
Problem Constants: BALCONY_HT 12 // balcony height in feet G 32 // gravitational acceleration PI 3.14159 POOL_DIAMETER 2 // diameter of pool in feet POOL_CENTER 35 // distance to the center of pool in feet CAPACITY 7 // pool capacity in gallons FILENAME “balloonValues.txt” // input data file Problem Inputs: balloon launch angle (theta) in degrees balloon launch velocity (v) in ft/sec thrower’s height in feet balloon diameter
Problem Outputs: See the instructions above.
Other variables: As needed
Instructions:  See Standards for Documentation of C Programs on the Resources page on Canvas.  Insert comments at the top and throughout each file.
Balloons diameter inches volume gallons 3 0.1 4 0.2 5 0.3 6 0.55 7 0.8 8 1.25 9 1.7
Read all instructions before beginning your work.
NOTE: Your submitted file(s) MUST be spelled and cased as instructed. [-5 points for not doing so.]
COMP1200c – Spring 2015– assign05 – p. 1 of 2
o Include the follow comments at the beginning of this (and ALL) files. // submitter’s name, GROUP # Grade of ZERO for files with submitter name not part of Canvas group // other group members’ names Type “none” if submitting alone. // assignment number Zero points for comments if no collaboration statement // date you completed the assignment // statement(s) about collaboration // a short narrative about what the file does o Use the algorithm given as comments throughout your program.  Use descriptive variable names.  Use Sample Input/Output as a guide.  Use Generate CSD to ensure correct indenting.  Represent ALL given values as constants.  Format the angle with 1 decimal place.  Format the building height with 2 decimal places.  Label output using the printf()function in sentence form.
 Use a while loop to read the balloonValues.txt data file until the end of file has been reached.  Think carefully about what needs to be done before the loop, in the loop and after the loop.  Use the switch/case structure to determine the amount of water in the balloon for a given balloon diameter.  Compute conversion: degrees to radians.  Compute distance.  Print the output with appropriate labels and decimals as shown. Print % with the percent of hits.
Sample Input/Output: 6 balloons hit the pool. 103 balloons were thrown. 5.83% balloons hit the pool. Balloon #97 filled the pool. 60.05 gallons of water spilled over the edge of the pool. Submit via Canvas: assign05.c C program file
Rough algorithm – INITIALIZATION while more data, get balloon input values from the data file one balloon at a time count balloon use balloon diameter to determine volume add balloon volume to total water compute distance is it a hit? add balloon volume to pool water count hit remember balloon number that finished filling the pool