Starting from:

$30

Homework 3 Solution

This assignment is worth 15 points and will be due at 11:00pm. All assignment deadlines are firm and the ability to submit your assignment will be disabled after the deadline elapses. No late work will be accepted. You are encouraged to start this assignment as soon as possible so that you have ample time to seek assistance should you experience difficulties completing or submitting this assignment.




This programming assignment does not have a single solution, and the assignment you submit must be your own original work. Collaboration with other students is not permitted on homework assignments. Any submission may be processed with comparison software and the results will be used to detect unacceptable collaboration between individuals. If you need assistance, you should only consult course staff regarding your program.




Your program must adhere to the course programming standards (available in the course packet and in Blackboard). Please review this document before submitting your assignment, because failure to adhere to it will result in a reduction in points. Your program must include the designated program header (~cs15x/student/hdrProg) at the top of the program (which can be inserted in vi using the hp shortcut while in command mode). The header must include an appropriate description of your program and must contain your official Purdue career account e-mail address. Also note that course standards prohibit the use of advanced programming concepts not yet introduced in the course, unless otherwise specified.




Each of the example executions provided below represents a single execution of the program. Your program must accept input and produce output exactly as demonstrated in the example executions. Your program will be tested with the data seen in the examples below and an unknown number of additional tests making use of reasonable data. Do not include any example outputs with your submission.




A single program file (with the .c extension) must be submitted electronically via the guru server. An example submission was conducted during the first week in lab00. Any attempts to submit via another method will be denied consideration. You may make multiple submissions before the deadline, but only the last attempt is retained and graded. All previous submissions will be over-written and cannot be recovered. The submission script will reject the submission of any file that does not compile. A program must compile to be considered for partial credit. You should always check the confirmation e-mail you receive after a submission to verify that you have submitted the correct file, to the correct assignment, and to the correct lab section. If you have a concern regarding how to submit work, please visit course staff prior to the assignment deadline.

Problem: Given from the user a radius value representing the lowest (#1) of three spheres used to create a snowman and as was the case in the first lab assignment you'd again like to make the middle (#2) sphere to have a radius that is half of the largest sphere with a top (#3) sphere radius that is half of the middle sphere. Calculate and display the radius, circumference, surface area, and volume for each sphere and the total combined volume and surface area of all three spheres.




With the additional requirement to implement user-defined functions, functions should be designed to reduce the duplicate of similar code and to reflect the ability to reuse functions. Each user-defined function should represent a single task in your larger program. The failure to make a good use of user-defined functions as described in lecture and in the course standards will result in a loss of points.




Example Execution #1:

Please enter the value of the largest radius - 10




Radius
#1
is:
10.00
Circumference #1 is:
62.83
Surface Area #1 is:
1256.64
Volume
#1
is:
4188.79



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Radius
#2
is:
5.00
Circumference #2 is:
31.42
Surface Area #2 is:
314.16
Volume
#2
is:
523.60



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Radius
#3
is:
2.50
Circumference #3 is:
15.71
Surface Area #3 is:
78.54
Volume
#3
is:
65.45



-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Total
Volume:


4777.84
Total
Surface
Area:
1649.34
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-




Additional Notes:




The input will be non-negative floating-point data.
All floating-point values are to be of the double type.



Use M_PI from math.h



The proper use of user-defined functions is a requirement of this assignment and all future assignments.



Course standards prohibit the use of programming concepts not yet introduced in lecture. For this assignment you can only consider material in the first 4 chapters of the book, notes, and lectures. Use of advanced programming constructs beyond this material would result in a loss of points.

More products