课堂作业一(16/05/04)

MyGitHub

Description: Create a program that asks for the radius of a circle and prints the area of that circle, using cin and cout. The whole program should be divided into two source files (.cpp). Hand in the source files and the head files which you create.

main.cpp

 #include<iostream>
using namespace std;
#include"circle.h"

int main()
{
	int s,r;
	circle circle;
	cout << "Please enter the radiu:";
	while (cin>>r)
	{
		cout <<"The area is "<< circle.calculatecircle(r) << endl;
		cout << "Please enter the radiu:";
	}
	return 0;
}

Circle.cpp

 #include "circle.h" 
 #include<math.h>
 #define pai 3.1415926

 double circle::calculatecircle(double r)
 {
double s;
s = r*r*pai;
return s;
 }
原文地址:https://www.cnblogs.com/mingtime/p/5462722.html