程序代写代做代考 C Programming Assignment 2

C Programming Assignment 2

C Programming Assignment 1
Due Thursday, September 13, 2018

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.

Programs:

1. Write a program that prompts the user to enter four integers and reads the four values with separate scanf statements. Write statements to find the cube of each value. Print the values and their cubes in a labeled table aligned as in the example shown below. Use five lines of output statements. Test your program with 3, 9, 12, 2
Number Cube
2 8
4 64
6 216
8 512

2. Write a C Program that will prompt a user to enter an amount of money between $0 and $1. Then using modulo, determine the minimum number of coins(quarters, dimes, nickels, and pennies) would total that amount. Read in the amount from the user as an int ($0.50 should be entered as 50) Hint: Use modulo…there was a similar challenge in section 2.6 of the book if you need help. Output the answer similarly to the example below.
e.g. “62 cents should be returned as 2 Quarters, 1 Dime, 0 Nickles, and 2 Pennies”

Test your program with 92 cents.

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)