There are 6 errors and I believe I found 4 of them. I can run the program, but I
ID: 3530287 • Letter: T
Question
There are 6 errors and I believe I found 4 of them. I can run the program, but I'm not getting the results that I need. It should be: Enter the radius of the circular paper in inches: 10 Length of the removed sector: 11.53 inch Max Volume 403.07 cubic inches I believe the other two problems are the equations. I just don't know what they should be. Please help me. #include #include #include // error. didn't include this using namespace std; const double PI = 3.141592654; void ConeVolume(double x, double n); int main() { double removedSectorLength; double PaperRad; double paperCupBaseRad; //r double paperCupHeight; //h double paperCupVol; double PaperCircum; double maxVolume; double x; // error. wasn't included <---- not too sure about this one // Program Introduction to User ... cout << " ************************************************" << " * Simple program that calculates a Max Volume *" << " * cup-like container from ciruclar paper sheet *" << " * with a pie-shaped wedge cut out. *" << " ************************************************ " // error. didn't have the " at the end << " " << endl; cout << fixed << showpoint << setprecision(6) ; cout << "Enter the radius of the circular paper in inches: "; cin >> PaperRad; cout << endl; x = 0.00; removedSectorLength = 0.0; PaperCircum = 2 * PI * PaperRad; cout << fixed << showpoint << setprecision(2); while (x <= PaperCircum) { paperCupBaseRad = PaperRad - (PaperCircum / (2 * PI)); paperCupHeight = sqrt(PaperRad * PaperRad - paperCupBaseRad * paperCupBaseRad); paperCupVol = (1.0 / 3.0) * PI * (paperCupBaseRad * paperCupBaseRad) * paperCupHeight; if (paperCupVol <= maxVolume) { maxVolume = paperCupVol; removedSectorLength = x; } x = x + 0.01; } cout << "Length of the removed sector: " << removedSectorLength << " inch"<< endl ; // error. didn't have ; at the end cout << " Max Volume " << maxVolume << " cubic inches"<< endl; // Simple Hold Screen Code for Command Prompt C++ Compilers char holdscr; // This character and section is to hold screen open cout << " Press a character and Enter to exit program. "; cin >> holdscr; return 0; }Explanation / Answer
#include <iostream>
#include <cmath>
#include <iomanip>
// error. didn't include this
using namespace std;
const double PI = 3.141592654;
void ConeVolume(double x, double n);
int main()
{
double removedSectorLength;
double PaperRad;
double paperCupBaseRad; //r
double paperCupHeight; //h
double paperCupVol;
double PaperCircum;
double maxVolume;
double x;
int holdscr;
// error. wasn't included <---- not too sure about this one
// Program Introduction to User ...
cout << " ************************************************"
<< " * Simple program that calculates a Max Volume *"
<< " * cup-like container from ciruclar paper sheet *"
<< " * with a pie-shaped wedge cut out. *"
<< " ************************************************ "
// error. didn't have the " at the end
<< " " << endl;
cout << fixed << showpoint << setprecision(6) ;
cout << "Enter the radius of the circular paper in inches: ";
cin >> PaperRad;
cout << endl;
x = 0.00;
removedSectorLength = 0.0;
PaperCircum = 2 * PI * PaperRad;
cout << fixed << showpoint << setprecision(2);
while (x <= PaperCircum)
{
paperCupBaseRad = PaperRad - (PaperCircum / (2 * PI));
paperCupHeight = sqrt(PaperRad * PaperRad - paperCupBaseRad * paperCupBaseRad);
paperCupVol = (1.0 / 3.0) * PI * (paperCupBaseRad * paperCupBaseRad) * paperCupHeight;
if (paperCupVol <= maxVolume)
{
maxVolume = paperCupVol;
removedSectorLength = x;
}
x = x + 0.01;
}
cout << "Length of the removed sector: " << removedSectorLength << " inch"<< endl ;
// error. didn't have ; at the end
cout << " Max Volume " << maxVolume << " cubic inches"<< endl;
// Simple Hold Screen Code for Command Prompt C++ Compilers char holdscr;
// This character and section is to hold screen open
cout << " Press a character and Enter to exit program. ";
cin >> holdscr;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.