Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)
image text in transcribed
image text in transcribed
image text in transcribed
2 #include 3 #include 4 using namespace std; 5 6 void PrintRectanglePerimeter double height, double width) { 7 double perimeter - 2.2 Cheight + width); 8 cout 20 double CalcRectanglePerimeter(double height, double width 11 double perimeter - 2.0 Cheight + width): 12 return perimeter: 13 } 14 void DoubleRectanglePerimeter(double height, double width) { 15 height = height 2.8; 16 width-width 2.0; 17 double perimeter -2.0Cheight - width); 18 cout > height >> width >> radius: 51 52 cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

=+7. What is progressive discipline?

Answered: 1 week ago