When asked to create a program to find the volume of any cone. given its radius...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
When asked to create a program to find the volume of any cone. given its radius and height, a programmer created this program to implement the formula V = It compiles, and it runs, but it gives completely incorrect results. A serious problem lies in the ComputeVolume function. Additionally, the programmer was confused about parameters and local variables. Make this function work correctly, and also improve its use of parameters, changing main as necessary. Note any other minor or stylistic errors you might and throughout the program. You can simply note changes on the program listing. double ComputeVolume ( double r, double h, double ans double r2 ) int main () { double radius , height , ans , r2; cout<<" Radius : "<< radius; cout<< " Height : " << height; ans ComputeVolume (radius , height ans , r2 ); cout<< " Volume :"<<ans; double ComputeVolume ( double r, double h, double ans , double r2) { r2 = r*r; ans (1/3) * 3.14 *r2*h; return ans; When asked to create a program to find the volume of any cone. given its radius and height, a programmer created this program to implement the formula V = It compiles, and it runs, but it gives completely incorrect results. A serious problem lies in the ComputeVolume function. Additionally, the programmer was confused about parameters and local variables. Make this function work correctly, and also improve its use of parameters, changing main as necessary. Note any other minor or stylistic errors you might and throughout the program. You can simply note changes on the program listing. double ComputeVolume ( double r, double h, double ans double r2 ) int main () { double radius , height , ans , r2; cout<<" Radius : "<< radius; cout<< " Height : " << height; ans ComputeVolume (radius , height ans , r2 ); cout<< " Volume :"<<ans; double ComputeVolume ( double r, double h, double ans , double r2) { r2 = r*r; ans (1/3) * 3.14 *r2*h; return ans;
Expert Answer:
Answer rating: 100% (QA)
1 The code will always return 0 Hence the volume for any values of radius and height is always 0 Thi... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are asked to create a scatter plot for number of hours spent playing computer video games and academic average. Now compute the Pearson r correlation coefficient. Here, again, are the data For...
-
A pyramid has a height of 481 ft and its base covers an area of 13.0 acres (Fig. P1.32). If the volume of a pyramid is given by the expression V = Bh, where B is the area of the base and h is the...
-
Use cylindrical shells to find the volume of the solid. 43. A sphere of radius r 44. The solid torus of Exercise 61 in Section 6.2 45. A right circular cone ith height h and base radius r
-
Consider a tank containing a liquid, and the rate of change of the liquid's height (h) with respect to time (t) is proportional to the difference between the current height and a reference height....
-
In an IE Matrix, do you believe it is more advantageous for a division to be located in quadrant II or IV? Why?
-
You just scored 40 points out of a possible 50 on your health information test. What percentage of available points did you earn?
-
Richmond Sporting Goods uses the LIFO inventory method and values its inven tory using the lower-of-cost-or-market (LCM) rule. Richmond Sporting Goods has the following account balances at May...
-
For each of the following costs, check the columns that most likely apply (both variable and fixed might apply for somecosts). Product Costs Direct nect Period Variable Fixed Raw materials Staples...
-
How do situational factors such as task interdependence, goal clarity, and resource availability influence team coordination, communication patterns, and ultimately, task performance outcomes ?
-
This is a new manufacturing corporation that issued $50000 common stock for cash on the first day. All overhead expenses are paid immediately by cash. To make it easy, there are no other operating...
-
In regulated monopolies, such as electric utility companies, there is evidence regulation provides: A. incentives to underinvest in capacity when the allowed rate of return is greater than the firms...
-
A company purchased a limited - life intangible asset for $ 1 , 1 6 2 , 5 0 0 on January 1 of Year 1 . It has a useful life of 1 5 years. Which amount should the balance sheet reflect for the limited...
-
Graham Potato Company has projected sales of $ 1 1 , 4 0 0 in September, $ 1 4 , 5 0 0 in October, $ 2 1 , 4 0 0 in November, and $ 1 7 , 4 0 0 in December. Of the company\'s sales, 3 0 percent are...
-
object to fall back down from max height. 2. A book falls straight down off a 3.2m shelf. How long it takes the book to reach the ground. 3. A rock is dropped straight down off a 7.5m building. How...
-
8) As shown in figure, a thin uniform rod AB of mass M-10 kg and length L-120 cm is hinged at end A to the flat floor. It initially stands vertically. If it is allowed to fall to the floor as shown...
-
Simplify these Boolean expressions as much as possible: a) ((A+D)'(C'+B')'+C)' b) A'B+CA'D+B'+D' c) (A+(AB)'+C(AB)')(A+BA'+B')
-
Yuengling, founded in 1827, is the oldest brewery in the United States. It has survived by severely limiting sales of the beer and creating a mystique about the brand. In areas where the beer is...
-
A parking lot charges $3 for the first hour (or part of an hour) and $2 for each succeeding hour (or part), up to a daily maximum of $10. (a) Sketch a graph of the cost of parking at this lot as a...
-
Sketch the graph of f by hand and use your sketch to find the absolute and local maximum and minimum values of f. (Use the graphs and transformations of Sections 1.2 and 1.3.) (a) f(x) = 1/2 (3x -...
-
Sketch the graph of a function that is continuous except for the stated discontinuity. (a) Discontinuous, but continuous from the right, at 2. (b) Removable discontinuity at 3, jump discontinuity at...
-
Determine whether the series is convergent or divergent. (a) (b) 1 + 1/8 + 1/27 + 1/64 + 1/125 + ... (c) 1 + 1/3 + 1/5 + 1/7 + 1/9 + ... -I n
-
Consider the purchases function of a manufacturing company. To overcome a downward profitability trend, management recently instituted a "just-in-time" system of acquiring raw materials for its...
-
Explain how creating a process map and internal threat analysis helps in determining the extent to which substantive testing is to be performed on the accounts associated with the supply chain and...
-
The following are routine procedures for the audit of the purchases process. For each procedure, (1) state whether it is a test of controls or a substantive test of transactions or balances, (2)...
Study smarter with the SolutionInn App