I have this problem i had to do for school and im a little confused on what i should put in my first while loop for my program.
Thanks for any help pointing me in the right direction!
Heres the problem.
http://img546.imageshack.us/img546/7454/problemfk.jpg
and heres the code i have so far.
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double boardArea;
double boardLength;
double boardWidth = 0.001;
//double bVolume, bHt;
double maxVolBoxBoardLn;
double maxVolBoxBoardWd;
double maxVolBoxHt;
double maxVolBox = 0;
double boxVolume;
double sqrSide;
double SqrSide = 0.001;
double minSide;
double maxvolume = 0.0;
double maxSqrSide;
cout << "Enter the area of the box" << endl;
cin >> boardArea;
while (boardWidth <= boardArea)
{
boardWidth;
}
double minside=0;
if (boardLength < boardWidth)
minside = boardWidth;
if (boardLength > boardWidth)
minside = boardLength;
while ( 2 * SqrSide <= minSide)
{
if (maxvolume > boxVolume)
{
maxvolume = boxVolume;
maxSqrSide = SqrSide;
}
else
SqrSide += 0.001;
}
boxVolume = (boardLength - 2 * sqrSide) * (boardWidth - 2 * sqrSide) * sqrSide;
cout<<"Length: "<<boardLength<<"Width: "<<boardWidth<<endl;
cout<<"The side of the square cutout is: "<<SqrSide<<endl;
return 0;
}