【vb精品源码栏目提醒】:网学会员为需要vb精品源码的朋友们搜集整理了java语言程序设计基础篇编程练习题7~10章 - 大学课件相关资料,希望对各位网友有所帮助!
//7.2/import javax.swing.class Fan final static int SLOW1 final static int MEDIUM2 final static int FAST3 private int speed private boolean on private double radius private String color FanspeedSLOWonfalseradius5colorquotbluequot void getSystem.out.printlnspeedquot quotonquot quotradiusquot quotcolor void set char c String sJOptionPane.showInputDialogquot请输入风扇的状态 Y开 N关quot cs.charAt0 ifcYcy ontrue System.out.printlnon sJOptionPane.showInputDialogquot请输入风扇的速度123quot speedInteger.parseInts sJOptionPane.showInputDialogquot请输入风扇半径quot radiusDouble.parseDoubles sJOptionPane.showInputDialogquot请输入风扇颜色quot colors public String toString ifontrue String squot状态 quotonquot 半径 quotradiusquot 风速 quotspeedquot 颜色 quotcolor return s else String squotfan is offquot return s public class LQ public static void mainString args Fan f1 new FanFan f2 new Fan f1.get f1.set System.out.printlnf1.toString f2.get f2.set System.out.printlnf2.toString ///7.4/import javax.swing.class Stock private String symbol private String name private double previousClosingPrice private double currentPrice StockString symbolString name this.symbolsymbol this.namename previousClosingPrice4.5 currentPrice5.0 void front doublepreviousClosingPriceDouble.parseDoubleJOptionPane.showInputDialogquot请 输入前 一天股票价格quot this.previousClosingPricepreviousClosingPrice void current double currentPriceDouble.parseDoubleJOptionPane.showInputDialogquot请输入当前股票价格quot this.currentPricecurrentPrice double changePercent return previousClosingPrice/currentPrice public class LQ public static void mainString args Stock snew Stockquot20135quotquot兴华quot JOptionPane.showMessageDialognulls.changePercent s.front s.current JOptionPane.showMessageDialognulls.changePercent ///7.5/import java.util.public class LQ public static void mainString args GregorianCalendar gnew GregorianCalendar JOptionPane.showMessageDialognullg.YEARquot:quotg.MONTHquot:quotg.DAY_OF_MONTH ///7.7/class Time private int hour private int minute private int second Time Calendar cCalendar.getInstance hourc.getc.HOUR minutec.getc.MINUTE secondc.getc.SECOND Timelong m long tsm/1000 secondintts60 long tmts/60 minuteinttm60 long thtm/60 hourintth24 int get1 return hour int get2 return minute int get3 return second public class LQ public static void mainString args Time t1new Time JOptionPane.showMessageDialognullt1.get1quot : quott1.get2quot :quott1.get3 Time t2new TimeSystem.currentTimeMillis JOptionPane.showMessageDialognullt2.get1quot : quott2.get2quot :quott2.get3 ///7.8/class Course private String name private String studentsnew String100 private int numberOfStudents public CourseString name this.namename public void addStudentString student studentsnumberOfStudentsstudent numberOfStudents ifnumberOfStudentsstudents.length-1 String snew Stringstudents.length2 forint i0iltstudents.lengthi sistudentsi studentss public String getStudents return students public int getNumberOfStudents return numberOfStudents public String getName return name ///7.11/class MyPoint private double x