×
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
When working on OCaml assignments, make use of pattern matching to simplify your code. It provides a clean and efficient way to handle different cases, especially for recursive functions and data structures like lists and trees. This can reduce complexity and improve readability.
News
Universities worldwide are seeing a surge in programming enrollment, as coding becomes an essential skill across disciplines. To meet growing academic pressures, more students are seeking online help for programming assignments and coursework.

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.