- #1
Mrencko
- 109
- 0
1. Homework Statement
calculate the area and perimeter of 2 rectangles(two objetcs and one builder), print the sides, area and perimeter, the function printrectangle must identify which side belongs to base and height...
the teacher suggest this in private: float side1 float side2
and this in public:
rectangle()
rectangle(float s1, float s2)
void printrectangle()
float calcarea()
float calcperimeter()
this is my code currently i don't have idea if i am ok, i don't get how to run my things in the main function, i need some help i am veery new and the teacher don't like to explain just say, that's wrong..
calculate the area and perimeter of 2 rectangles(two objetcs and one builder), print the sides, area and perimeter, the function printrectangle must identify which side belongs to base and height...
the teacher suggest this in private: float side1 float side2
and this in public:
rectangle()
rectangle(float s1, float s2)
void printrectangle()
float calcarea()
float calcperimeter()
The Attempt at a Solution
this is my code currently i don't have idea if i am ok, i don't get how to run my things in the main function, i need some help i am veery new and the teacher don't like to explain just say, that's wrong..
C:
#include<iostream>
using namespace std;
class rectangle {
private:
float b,h;
public:
rectangle( float b,float h);
void printrectangle();
float calcarea();
float calcperimeter();
};
rectangle::rectangle(float a, float b)
{
b=b1;
h=h1;
}
void rectangle::calcarea(float b1,float h1)
{
float area;
area=h1*b1
}
void rectangle::calcperimeter(float b1,float h1)
{
float perimeter;
perimeter=(2*b1)+(2*h1)
}
void rectangle::printrectangle(float perimeter, float area)
cout<<"input the base"<<endl;
cin>>b1;
cout<<"input the height"<<endl;
cin>>h1;int main()
{
rectangle ready;
ready.calcperimeter()
return 0;
}
Last edited by a moderator: