云南大学软件学院
实验报告
姓名:王增伟学号:20111120083班级:软件工程日期:2014.10.21成绩:
JAVA实验五
一、实验目的:
Applying OO Concepts Using Java
二、实验要求:
Create a class called Circle.java with fields named radius,area, and diameter.Include methods named setRadius(),getRadius,and computeDiameter(),which calculates the circle's diameter,and computeArea(),which computes the circle's area.
Hint:diameter of a circle is twice its radius.
Hint:area of a circle is3.14multiplied by the square of the radius.
Create a class called TestCircle.java whose main method declares 2Circle http://www.doczj.com/doc/c2bbc38503d276a20029bd64783e0912a2167cdd.htmling setRadius()method,assign one Circle a small radius value and assign another a larger radius value.Call
computeDiameter()and computeArea for each circle and display the results.
Output result of using command input"58":
The area of a is78.5
The diameter of a is10.0
The area of b is200.96
The diameter of b is16.0