Question

NEED HELP WITH THIS!!

Open with Drive N // Test1B-Debug.cpp .This is a program with 6 errors in it Find and fix each error. // Simple Container mad

Debug the PaperCup-Debug.cpp Create a Debug 2 Heading for your Debug Lab document. . The program has ó errors/bugs . Document

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\

#include <iostream>
#include <cmath>
#include <iomanip>
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;

// Program Introduction to User ...
cout << "\n\t ************************************************"
<< "\n\t * Simple program that calculates a Max Volume *"
<< "\n\t * cup-like container from ciruclar paper sheet *"
<< "\n\t * with a pie-shaped wedge cut out. *"
<< "\n\t ************************************************"   
<< "\n\n"<<endl;   
  
cout << fixed << showpoint << setprecision(6);   

cout << "Enter the radius of the circular paper in inches: ";
cin >> PaperRad;
cout << endl;

double x = 0.00;
removedSectorLength = 0.0;
PaperCircum = 2 * PI * PaperRad;

cout << fixed << showpoint << setprecision(2);

while (x <= PaperCircum)
{
paperCupBaseRad = PaperRad - (x / (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;
cout << "\nMax 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 << "\n\n\tPress a character and Enter to exit program. ";
cin >> holdscr;   

return 0;
}

Output:

Add a comment
Know the answer?
Add Answer to:
Open with Drive N // Test1B-Debug.cpp .This is a program with 6 errors in it Find and fix each er...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Find and fix the errors in this C++ code: * This program illustrates a variety of...

    Find and fix the errors in this C++ code: * This program illustrates a variety of common loop errors. * Fix the errors in each section. */ #include <iostream> using namespace std; int main() { cout << "Welcome to Loop World" << endl; // SECTION I: update comment below on how you fixed this section's code, and tests run // FIX = // TESTS: cout << endl; cout << "******************" << endl; cout << "Section I" << endl; cout <<...

  • C++ problem. Please just find and fix the errors and highlight it afterwards. Do not add...

    C++ problem. Please just find and fix the errors and highlight it afterwards. Do not add any new comments or remove comments from teachers. Thank you very much *R 2B PROGRAM 1B: INSERTION SORT Find and rix errors. Ron the program once and save the outpat as a conment at the end of the source file Changed by: IDE #include <iostream> using namespace std: void insertionSort (int aryll, int size) int main double list(1001-(50.1, 30.2, 80.3, 10.5, 30.2, 40.9, 90.8,...

  • A) Fix any errors to get the following program to run in your environment.               B)...

    A) Fix any errors to get the following program to run in your environment.               B) Document each line of code with comments and describe any changes you had to make to the original code to get it to work. C) Write a summary of what your final version of the program does. You may also add white space or reorder the code to suit your own style as long as the intended function does not change. Program 3 #include...

  • Please help fix my code C++, I get 2 errors when running. The code should be...

    Please help fix my code C++, I get 2 errors when running. The code should be able to open this file: labdata.txt Pallet PAG PAG45982IB 737 4978 OAK Container AYF AYF23409AA 737 2209 LAS Container AAA AAA89023DL 737 5932 DFW Here is my code: #include <iostream> #include <string> #include <fstream> #include <vector> #include <cstdlib> #include <iomanip> using namespace std; const int MAXLOAD737 = 46000; const int MAXLOAD767 = 116000; class Cargo { protected: string uldtype; string abbreviation; string uldid; int...

  • Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std;...

    Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std; /* * Calculate the square of a number */ float square (float x) { return x*x; } /* * Calculate the average from a list of floating point numbers */ float average(vector<float>& values) { float sum = 0.0f; float average; for (float x : values) sum += x; average = sum / values.size(); return average; } /** Calculate the standard deviation from a vector...

  • I need to implement a program that requests a x,y point and the radius of a...

    I need to implement a program that requests a x,y point and the radius of a circle. then it figures out the area and circumference using an overloaded operation. The full instructions, what I have and the errors I have are below. A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, pointType, that can store and process a point in the x-y plane. You should then perform operations on the point, such as...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT