Sep 18, 2013 at 2:13pm UTC
i don't whats wrong i double check the the spelling and all it still wont compile please me.
here the main program
//Chl14LAb2.cpp
//calculates and display the cost of laying sod
//created/revised by <michelle roxas> on <9/18/2013>
# include <iostream>
# include <iomanip>
# include <"Rectangle.h"
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::setprecision;
int main()
{
//create Retangle object
Rectangle lawn;
//declare variables
double lawnLength = 0.0;
double lawnWidth = 0.0;
double priceSqyd =0.0;
double lawnArea = 0.0;
double totalPrice = 0.0;
//get length, width, and sod price
cout << "Lenth (in feet): ";
cin >> lawnLenght;
cout << "width (in feet): ";
cin >> lawnWidth;
cout << "Sod price (per square yard): ";
cin >> priceSqyd;
//assign input to Rectanglr object
lawn.setDimensions(lawnLength, lawnWidth);
//calculate area and total price
lawnArea = lawn.calcArea() 9.0;
totalPrice = lawnArea * priceSqyd;
//display area and total price
cout<< fixed << setprecision(2)<<endl;
cout <<"square yards: "<<lawnArea <<endl;
cout <<"Total price: $" << totalPrice <<endl;
return 0;
}//end of main function
and this is the header
//Rectangle.h
//declaration section
class Rectangle
{
public:
Rectangle();
void setDiemensions(double, double);
double calcArea();
double calcPerimeter();
private():
double length;
double width;
};
//implementation section
Rectangle::Rectangle()
{
length =0.0;
width = 0.0;
}// end of default constructor
void Rectangle::setDimensions(double len, double wid)
{
// assigns lenght and width tp private data members
if (len > 0.0 && wid > 0.0)
{
length =len;
width -wid;
} //end if
}//end of setDimensions method
double Rectangle::calcArea()
{
return length * width;
}//end of calcArea method
double Rectangle::calcPerimeter()
{
return (length + width) * 2.0;
}//end calcPerimeter method
Last edited on Sep 18, 2013 at 2:35pm UTC
Sep 18, 2013 at 2:15pm UTC
# include <"Rectangle.h"
there's one clue.
Sep 18, 2013 at 2:20pm UTC
i know its on the header, saying rectangle undeclare
Sep 18, 2013 at 2:29pm UTC
you really need to read up on this stuff then mate.
remove the angle bracket and see what happens.
Sep 18, 2013 at 2:34pm UTC
i just realize that cause i was getting frustrated, so i took it out and all this errors came out.
Last edited on Sep 18, 2013 at 2:35pm UTC
Sep 18, 2013 at 2:56pm UTC
yea but I even gave you the line and you still couldnt fix it?
Sep 18, 2013 at 2:59pm UTC
yah, i looked everyline that says whats wrong on it and still didn't work
Sep 18, 2013 at 3:43pm UTC
1) Please use code tags when posting code, so that we can read it properly.
2) Just telling us "it won't compile" is useless . Tell us what the compiler errors are and what lines they occur on. You have this information, so why on earth would you withhold it from the people who you'd like to help you? It's like you don't want us to be able to find your problem!
3) Have you fixed the bad include statement that mutexe pointed out?
Sep 19, 2013 at 7:36am UTC
check your spelling of methods between the cpp and h file.
and some weird stuff like:
lawnArea = lawn.calcArea() 9.0;
width -wid;
etc etc
Last edited on Sep 19, 2013 at 7:37am UTC
Sep 23, 2013 at 4:41pm UTC
i have fix it thanks you guyz and also i learned how to use
this easy way to read the code lol silly me