《Java程序设计案例教程》考试卷A答案.doc
《《Java程序设计案例教程》考试卷A答案.doc》由会员分享,可在线阅读,更多相关《《Java程序设计案例教程》考试卷A答案.doc(5页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Java程序设计案例教程考试卷A答案(一)略(二)import java.util.Scanner;public class QuestionA2 public static void main(String args) Scanner sc = new Scanner(System.in);System.out.print(输入圆的半径:);double radius = sc.nextDouble();System.out.println(圆的周长: + 2 * Math.PI * radius);System.out.println(圆的面积: + Math.PI * Math.pow(
2、radius, 2);(三)import java.util.Scanner;public class QuestionA3 public static void main(String args) Scanner sc = new Scanner(System.in);String s;int year;doSystem.out.print(输入年份:);year = sc.nextInt();if(year % 4 = 0 & year % 100 != 0 | year % 400 = 0)System.out.println(year + 是闰年);elseSystem.out.pri
3、ntln(year + 不是闰年);System.out.print(继续输入年份吗?(y/n));s = sc.next();while(s.equalsIgnoreCase(y);(四)public class Cuboid /长方体private double length, width, height;/长、宽、高public Cuboid(double length, double width, double height) /构造方法if(length 0 & width 0 & height 0)this.length = length;this.width = width;th
4、is.height = height;elseSystem.exit(0);public double getLength() return length;public void setLength(double length) this.length = length;public double getWidth() return width;public void setWidth(double width) this.width = width;public double getHeight() return height;public void setHeight(double hei
5、ght) this.height = height;public double calSArea() /计算表面积return 2 * (length * width + width * height + height * length);public double calVolume() /计算体积return length * width * height;(五)public class Cube extends Cuboid /正方体private double side;/边长public Cube(double side) /构造方法super(side,side,side);pub
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Java程序设计案例教程 Java 程序设计 案例 教程 考试卷 答案
限制150内