• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
milk、
博客园    首页    新随笔    联系   管理    订阅  订阅
课堂作业一(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;
 }
posted on 2016-05-05 17:44  milk、  阅读(102)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3