Java实验汇报修正版.docVIP

  • 14
  • 0
  • 约6.31千字
  • 约 7页
  • 2017-05-04 发布于四川
  • 举报
Java实验汇报修正版

天津商业大学学生实验报告 共 NUMPAGES 7页,第 PAGE 7页 制表单位:设备处 开课实验室:现代信息交流中心403 开课时间: 2015年3月1日 实验报告:2015年4月8日 学院名称信息工程学院年级、专业、班信管1303班学号姓名张云森同组姓名无课程名称Java程序设计实验项目名称Java面向对象程序设计(1)指导教师尉斌实验类型验证 √ 综合 □ 设计 □ 创新 □成绩教师评语 教师签名: 年 月 日实验目的:熟悉类、属性、构造方法、普通方法、对象的使用方法。 二、实验内容: (抄写课本296页8.2、8.7、8.8的题目至此。抄写英文即可) 8.2 (The stock class)Following the example of the Circle class in $8.2,design a class named Stock that contains: A string data field named symbol for the stock’s symbol. A string datd field named name for the stock’s name. A double data field named previousClosingPrice that stores the stock price for the previous day. A constructor that creates a stock with specified symbol and name. A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice. Draw the UMLdiagram for the class.Implement the class.Write a test program that creates a Stock object with the stock symbol JAVA,the name Sun Microsystems Inc,and the previous closing price of 4.5.Set a new current price to 4.35 and display the price-change percentage. 8.7(The Account class)Design a class named Account that contains: A private int data field named id for the account(default 0). A private double 三、源代码清单: 1、源代码清单 方法一:package 实验2; public class shiyan1 { public static class A{ private String number1; private double newPrice; public static void main(String[]args){ A symbol= new A(); System.out.println(The stock number is :+symbol.number1); A name=new A(中国银行); System.out.println(The stock name is :+1); A Price=new A(3900,4000);{ System.out.println(The stock PreviousPrice is :+Price.oldPrice); System.out.println(The stock CurrentPrice is :+Price.newPrice); System.out.println(The stock getChangePercent is :+Price.getChangePercent()); } }

文档评论(0)

1亿VIP精品文档

相关文档