×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

C++ Program to Create Area Calculation System Assignment Solution

July 11, 2024
Dr. Asha Campbell
Dr. Asha
🇸🇬 Singapore
Programming
A Ph.D. graduate in Computer Science from McGill University, Dr. Campbell has eight years of experience under her belt. Having successfully completed over 800 Perl Homework assignments, her comprehensive understanding of Perl programming concepts and dedication to academic excellence make her a trusted mentor for students seeking guidance.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Use well-structured shaders to optimize rendering and ensure efficient resource management. Start with simple shapes, gradually adding complexity, and debug in small steps to identify errors easily.
News
An open-source framework that allows developers to create rich Python applications in the browser using HTML's interface, bridging the gap between web development and Python scripting.

Instructions

Objective

Write a program to create area calculation system in C++.

Requirements and Specifications

Assignment 3

Write a C++ homework application (including algorithm) that uses a “void” function, “CalculateArea”, to calculate the area of a circle. The function uses two formal parameters (i.e., “radius” [pass by value] and “area” [pass by reference]). The function calculates the area using the formula (i.e., PI * radius2).

The application requires a sentinel controlled loop where program prompts for continuing and expects an entry of ‘Y’ or ‘y’ using the variable “cont”. Within the loop, the application provides for allowing the user to enter the radius of the circle, calls the “CalculateArea” function and displays the value of the circle’s area.

Upload to the Canvas “Assignment 3 Submission” area.

Note: Keep in mind the 3 requirements for functions

  • Function Declaration
  • Function Definition
  • Function Call

Source Code

#include #define PI 3.1416 using namespace std; // Function declaration void CalculateArea(double radius, double &area); int main() { // Define variable to store user input char cont; double radius; // Create variable to store area double area; // Begin with loop while(true) { cout << "Please enter the radius of the circle: "; cin >> radius; // Calculate CalculateArea(radius, area); cout << "The area of the circle with a radius of " << radius << " is: " << area << endl; // Ask if s/he wants to continue cout << "Do you want to calculate a new area? (y/n): "; cin >> cont; if(cont == 'n' || cont == 'N') { break; } } } /** * @brief Function to calculate the area of a circle given its radius. * The function received two parameters. The area (passed by value) and the area (passed by ref) * */ void CalculateArea(double radius, double &area) { // Calculate area area = PI*radius*radius; }

Related Samples

Explore our free programming assignment samples showcasing real-world applications and solutions. Enhance your understanding with practical examples in operating systems, Haskell, Java, embedded systems, C++ and C programming. Discover insights and inspiration for your next project or academic endeavor.