Image

Imagebrockbrockbrock wrote in Imagecpp

Listens: Groove Armada - Edge Hill

fuck CS107

ok heres the assigment i told you about
i didn't really understand what they wanted as output so i just pretty much have every possible variation of Area and length as a "cout" in this program

also we had to modify rectang.h to add in the diagonal() member function
the modifications by me are in red

*anyway* , it compiles and im pretty sure it does what it should...



[begin proj7.cpp]

// CS107 - Spring 2002 - Assignment #7 - Brock Fansler - Wed 9 am

#include
[Error: Irreparable invalid markup ('<iostream.h>') in entry. Owner must fix manually. Raw contents below.]

ok heres the assigment i told you about
i didn't really understand what they wanted as output so i just pretty much have every possible variation of Area and length as a "cout" in this program

also we had to modify rectang.h to add in the diagonal() member function
the modifications by me are in red

*anyway* , it compiles and im pretty sure it does what it should...

<lj-cut>
<blockquote>
[begin proj7.cpp]

// CS107 - Spring 2002 - Assignment #7 - Brock Fansler - Wed 9 am

#include <iostream.h>
#include "xrect.h" // fun with 5.15
#include <math.h> // using some mathy math

double doorWidth; // define the sides
double doorLength;
int slatsinches = 4; // slats are 4 inches wide
double slatsCut;
int evenSlats;

int main()
{
cout << "Using a Z frame door" << endl; // tell user whats going on
cout << "Input the length: "; // }
cin >> doorLength; // }
cout << "Input the width: "; // |- gain input of door
cin >> doorWidth; // }
cout << "Thank you!" << endl; // }

Rectangle gate(doorLength, doorWidth); // define gate
Rectangle slat(doorLength, slatsinches); // define slat
Rectangle door(doorLength, doorWidth); // define door

// Find the slat wood as given in the book
slatsCut = door.area()/slat.area();
evenSlats = ceil(slatsCut);

/*
// Ways to see if everythings going ok

cout << "evenslats: " << evenSlats << endl;
cout << "slatscut: " << slatsCut << endl;

*/

cout << "Total slats needed: " << evenSlats << endl;
cout << "Total wood cut " << endl;
cout << " Door total area: " << door.area() << " cubic inches" << endl;
cout << " Slats wood area from needed slats: " << slat.area()*evenSlats << " cubic inches" << endl;
cout << " Z wood " << endl;
cout << " Z total wood area: " << ((doorLength*slatsinches)*2) + (gate.diagonal()*slatsinches) << " cubic inches" << endl;
cout << " Z diagonal length: " << gate.diagonal() << " inches" << endl;
cout << " Aboslute Total needed to be cut: " << ((doorLength*slatsinches)*2) + (gate.diagonal()*slatsinches) + slat.area()*evenSlats << " cubic inches" << endl;

return 0;
}

[end proj7.cpp]
</blockquote>
<hr>
<blockquote>
[start xrect.h]
#ifndef RECTANGLE_CLASS
#define RECTANGLE_CLASS
#include <math.h>

// maintains measurement properties of a rectangle
class Rectangle
{
private:
// length and width of the Rectangle object
double length,width;
public:
// constructor
Rectangle(double l = 0.0, double w = 0.0);

// compute rectangle measurements
double perimeter();
double area();
<font color="#808000"> double diagonal();</font>

// data access functions
double getLength();
double getWidth();

// data update function
void setSides(double l, double w); // update dimensions
};

// ***********************************************************
// Rectangle class implementation
// ***********************************************************

// implementation of the Rectangle constructor
Rectangle::Rectangle(double l, double w): length(l), width(w)
{}

// the perimeter is twice the sum of the length and width
double Rectangle::perimeter()
{
return 2.0 * (length + width);
}

// the area is the product of the length and width
double Rectangle::area()
{
return length*width;
}

// return the value of the length attribute
double Rectangle::getLength()
{
return length;
}

// return the value of the width attribute
double Rectangle::getWidth()
{
return width;
}

<font color="#808000">// rectangle diagonal
double Rectangle::diagonal()
{
return sqrt( width*width + length*length);
}
</font>
// assign new values for the length and width
void Rectangle::setSides(double l, double w)
{
length = l;
width = w;
}

#endif // RECTANGLE_CLASS
[end xrect.h]
</blockquote>