Question: Part 2: Variables and basic functions This assignment is still attempting to ease you in to programming in C Ifyou programmed before; don't worry. The

 Part 2: Variables and basic functions This assignment is still attemptingto \"ease you in\" to programming in C Ifyou programmed before; don'tworry. The problems are about to be more challenging. In the meantime,you should solve these problems using (reusable) functions for a bit more

Part 2: Variables and basic functions This assignment is still attempting to \"ease you in\" to programming in C Ifyou programmed before; don't worry. The problems are about to be more challenging. In the meantime, you should solve these problems using (reusable) functions for a bit more of a challenge (experienced programmers ONLY). If A2 was too hard, hopefully this will restore some confidence. Make a new project with a single .cpp file titled A3_.cpp, where is your first initial and last name. Put a main method in the .cpp file. In the main method, make a new constant (const) double variable named MY_P|. MY_P| should be equal to 3.14159. Make two variables (double data type) named radius and diameter. Set the diameter to 2 and radius is always diameter / 2. 0 To test your code, you can modify the value of radius and make sure your code works for different values. 0 Set the value back to 2 before submitting your work but write comments stating the values you tested and the results you got. Area of a Circle: Make a variable areaCircle (a double) and calculate the area of a circle with the given radius (the variable above). Recall that the area of a circle is pi * r2 but there is no need for a square function. You just need * for multiply. Use printf to write a message about the area of the circle. Volume of a Cylinder: When calculating the volume of a cylinder, we will make the height ofthe cylinder equal to the diameter. You should test that the cylinder volume calculation works for multiple different diameters. Make a variable volumeCyl (double) that stores the volume of a cylinder. Use printf to write a message about the volume ofthe cylinder. Volume of a cylinder (intro to functions): Notice how much nicer it would be if we just wrote the area of a circle code just once? Incorrect Volume Try to calculate the volume of a sphere with integers only: 4/3 * pi * r * r * r To make sure each number is an integer and NOT a double or float, you can put (int) in front of each non-integer. Something like: int sphereVol = 4 / 3 * (int) MY_P| * (intjradius *(int) radius * (int) radius; Next, calculate sphereVo|2 as the correct calculation but cast the final number to be an int. That would look something like: int sphereVo|2 = (int)(4 / 3 * MY_P|.......); Calculate sphereVol3 which CORRECTLY calculates the volume of the sphere. SphereVol3 should be a double. Finally, using printf statements to output the values (and meaningful messages) of sphereVol, sphereVolZ, and sphereVol3. Printf is a function that lets you output messages to the screen. It has a format like this: printf(\"Some message to output %i\printf("Some message to output \ %i \ ", 3); outputs Some message to output 3 Calculating Cube Volume Finally calculate the volume of a cube with dimensions "diameter" x "diameter" x "diameter" where "diameter" is the diameter variable you made at the start of the program. Output a reasonable message using printf that is consistent with the previous messages. Submitting Submit your .cpp file (and only that file) to Brightspace for Assignment 3. A quick reminder, ensure that your code compiles. Also we will check all submissions for plagiarism (like we always do) using MOSS. Even giving you as much code as we did, your projects should not look alike

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!