C Programming Assignment 2
For each of the programs assigned below, submit the following:
· Copy of the source code (.c) saved as an electronic attachment to Assignment 1 located in Canvas under Assignments. Do not submit the entire project.
· Screen shot of your output either as a photo file or pasted into a word document submitted in the same place.
WHEN SUBMITTING ASSIGNMENTS in CANVAS PLEASE ADD ALL FILE BEFORE SUBMITTING ASSIGNMENT. DO NOT ATTACH ONE FILE THEN SUBMIT, THEN A SECOND FILE AND SUBMIT. For this assignment, there are three programs, so you will submit 3 .c files and 3 screenshots of output. You can submit the output as three separate files or you can paste the images into one word doc. This means you will submit four or six files….attach all of them and hit submit one time only.
Observe the following guidelines:
· Begin each program with a comment section which contains the following:
Program name
Author’s name
Due date
A description of what the program does.
· Use comments within the source code to label sections of your program.
· In general, use lower case letters for variable names. Variable names should be mnemonic. Separate words in a variable name with an underscore or begin the second word with an uppercase letter.
· Indent 2-4 spaces (optimally 3) within main. The editor should take care of proper indenting.
· Since we have not studied the math library yet, use multiplication (x*x or x*x*x) to square or cube a value.
3) Calculate the volume of a water bottle shown below. The bottle is made up of 2 sections, a cylindrical piece and a conic piece.
Define PI as a constant using one of the methods mentioned in class.
Prompt the user for the radius of the spherical and conic portion and the height of the cylindrical portion and the height of the conic portion. Calculate volumes of the spherical portion, the conic portion, and the total volume of the bottle.
Use the following formulas:
Volume of cylinder:
Volume of cone:
Print the individual volumes of the cylinder and conic parts of the water bottle as well as the total volume of the water bottle. Print your answers to 4 decimal places.
Test with values r(cyl and cone) = 5 cm, height(cyl) = 8 cm, and h(cone) = 3 cm.
r(cyl)
height(cone)
r(cone) = r(cyl)
Height(cyl)