Question
This is C++. I am working on a code that I just can't figure out. For some reason, I can't get height and width to
This is C++. I am working on a code that I just can't figure out. For some reason, I can't get height and width to double for doubling the Rectangle Perimeter among some other things. Help would be much appreciated. Thanks! Heres the instructions and what I have so far:
Part 1: Fix it
The template code provided to you is broken; your first job is to fix it. You will need to attempt to compile and run the code, interpret the error messages generated, and take steps to identify and resolve the problems.Hint: you will need to include code you wrote in the prep lab for this chapter.
Just getting your submission to compile and execute should be enough to pass the first test in the test suite. (i.e. you will earn some points) - but more work will be required to get everything working properly
Part 2: Organize it
Utilize function prototypes (declarations) to enable you to place all custom function definitions BELOW the main function. This part of the lab will be worth 10 points and will be graded directly by the TAs. To reiterate - when you have completed this lab main should be the first function definition to appear in your source code. Use function prototypes to make this possible.
Part 3: Write it
Implement the following additional functions:
- CalcCircumferenceOfCircle : this function accepts a single double argument - the value of the radius of a circle. The function computes and returns thecircumference (as a double value) of a circle with such a radius.
- CalcAreaOfCircle : this function accepts a single double argument - the value of the radius of a circle. The function computes and returns the area(as a double value) of a circle with such a radius.
- CalcVolumeOfSphere : this function accepts a single double argument - the value of the radius of a sphere. The function computes and returns thevolume (as a double value) of a sphere with such a radius.
- Swap : this function is to be overloaded so that there are two versions, one that accepts two ints as arguments, and another that accepts two doubles as arguments. Both functions return void. The purpose of these functions is to "swap" or exchange the values of the two arguments. For example, if a program were to call Swap(valueA, valueB); with valueA set to 5 and valueB set to 7 before the call; then after the call valueA would now be set to 7, and valueB would contain 5.
Important Notes: These new functions are not called in the provided main function - nor should they be. As with the rectangle functions you developed in the prep lab - these additional functions will be tested solely using unit tests. The unit tests from the prep lab have also been imported and will be used to continue to ensure that your rectangle functions are operating properly. As a reminder - you should use function prototypes above your main function for these functions, and place their definitions below the main function. Even though main does not call these new functions, the unit tests will not operate properly if you do not follow this pattern.
Assumptions and additional information
- You should/must use the value 3.14 for Pi. You may utilize a global constant to store this value. Failure to utilize 3.14 will result in failed tests (because your results will not match ours).
- You must utilize function prototypes as described in the lab. That is, main should be the first function definition that appears in your code (see "Part 2"). (10 pts)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started