

Question 1- 1.cpp code:
#include #include using namespace std;
double SquareRoot(double d)
{
double x=1;
for(int i=0;i<1000;++i)
{
double t=d/x;
x=(x+t)/2;
}
return x;
}
int main()
{
double res=SquareRoot(17);
cout.setf(ios::fixed);
cout << setprecision(4) << res << endl;
return 0;
}
Rectangle.cpp code
#include "Rectangle.h"
Rectangle::Rectangle(int h,int w)
{
height=h;
width=w;
}
Rectangle::Rectangle(const Rectangle &other)
{
height=other.height;
width=other.width;
}
Rectangle & Rectangle::operator=(const Rectangle &other)
{
height=other.height;
width=other.width;
return *this;
}
int Rectangle::getheight()
{
return height;
}
int Rectangle::getwidth()
{
return width;
}
void Rectangle::setheight(int h)
{
height=h;
}
void Rectangle::setwidth(int w)
{
width=w;
}
int Rectangle::getArea()
{
return height*width;
}
int Rectangle::getCircumference()
{
return 2*(height+width);
}
Question 2- 2.cpp code:
#include#include "Rectangle.h"
using namespace std;
int main()
{
Rectangle r(8,5);
cout<<"The area is:"<<r.getArea()<<endl;
cout<<"The circumference is:"<<r.getCircumference()<<endl;
r.setheight(10);
r.setwidth(8);
cout<<"After the chage"<<endl;
cout<<"The area is:"<<r.getArea()<<endl;
cout<<"The circumference is:"<<r.getCircumference()<<endl;
return 0;
}
Rectangle.cpp 2 part code:
#ifndef _RECTANGLE_H
#define _RECTANGLE_H
class Rectangle
{
private:
int height;
int width;
public:
Rectangle(int h=1,int w=1);
Rectangle();
Rectangle (const Rectangle &other);
Rectangle & operator=(const Rectangle &other);
int getheight();
int getwidth();
void setheight(int h);
void setwidth(int w);
int getArea();
int getCircumference();
};
#endif
Score:98
代写CS&Finance|建模|代码|系统|报告|考试
编程类:C++,JAVA ,数据库,WEB,Linux,Nodejs,JSP,Html,Prolog,Python,Haskell,hadoop算法,系统
金融类:统计,计量,风险投资,R语言,Python语言,Matlab,建立模型,数据分析,数据处理
服务类:Lab/Assignment/Project/Course/Qzui/Midterm/Final/Exam/Test帮助代写代考辅导






本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝或者Upwork交易!
E-mail:[email protected] 微信:BadGeniuscs 工作时间:无休息工作日-早上8点到凌晨3点
如果您用的手机请先保存二维码到手机里面,识别图中二维码。如果用电脑,直接掏出手机果断扫描。

