Question: Dev C++ language For this assignment, write a program that uses functions to calculate the diameter , the circumference , or the area of a

Dev C++ language

For this assignment, write a program that uses functions to calculate the diameter, the circumference, or the area of a circle, given the circle's radius. First, your program should display a prompt for the user:

Please enter an 'A' to compute the area, a 'C' to compute the circumference, or a 'D' to compute the diameter, followed by the radius of the circle, or enter 'Q' to quit:

The program will need to read two input values: the first is a single character which specifies the calculation ('A' for area, 'D' for diameter, or 'C' for circumference), and the second is a floating point value corresponding to the radius, separated by a space. The program should "echo" (or repeat back to the user) the input data, and the output should be printed with descriptive labels.

For example, if the user's input is ...

A 6.75

... then your program should output ...

The AREA of a circle with radius 6.75 is: 143.14.

The program should repeat its initial prompt until the user enters 'Q' to quit, at which point the program should exit.

Your program should #include the library; as we have recently discussed, this library provides the pow() function, and it also provides M_PI, a symbolic constant representing the value of pi (approximately 3.14159265). In order to use M_PI, however, the GCC compiler included with Dev-C++ also requires that you include the line #define _USE_MATH_DEFINES, a preprocessor directive which must appear first. So, the first few lines of your program should look something like this:

#define _USE_MATH_DEFINES #include #include

Your program should use the cin input stream to read both the character and the floating-point value into two different variables of the appropriate types. Remember that cin is type sensitive, so you should read the character into a char variable first. You may use either the if-else or switch control statement in your program.

Remember that the three computationsfinding the circumference, finding the area, and finding the diametermust be implemented in your program as functions! All three functions should include function prototypes, and all three should accept the radius as an argument and return the result as a floating-point number. See the "Computation, Part 2" lecture notes for an example of how the area function might be implemented; use this as a guide for writing the functions which compute the diameter and circumference.

Once you have your functions working as part of your main.cpp program file, you should split your functions into a separate header and driver file, with the header linked to the driver and to the main.cpp file with an #include directive, as shown in the "Computation, Part Two" lecture notes. Your resulting program should consist of three files: the main.cpp file, the header file, and the driver file.

Finally, here are the mathematical formulas that your program will need. (You will of course need to rewrite these as C++ expressions.)

Area = M_PI * radius2 Diameter = 2 * radius Circumference = 2 * M_PI * radius

This assignment is worth 30 points and is due by the end of the day on Tuesday, February 9th. When you have completed your work, submit your work to Canvas in the form of a compressed ZIP archive containing all of your program files.

(When you are ready to submit your work, choose "Clean" from the "Execute" menu in Dev-C++ to delete any compiled object files from your project. Then, close Dev-C++, open your project folder in the File Explorer, select all of the files within it, right-click the collection, and choose "Send To Compressed Folder" from the context menu. The files to be compressed to a ZIP archive, and this is the archive that you should submit to Canvas. Note that the archive must be in ZIP format; 7Zip, RAR, or other archive formats will not be accepted.)

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 Databases Questions!