九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOC文檔下載  

Java程序設(shè)計實驗報告實驗報告冊.doc

  • 資源ID:116422954       資源大?。?span id="24d9guoke414" class="font-tahoma">731.88KB        全文頁數(shù):62頁
  • 資源格式: DOC        下載積分:13積分
快捷下載 游客一鍵下載
會員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要13積分
郵箱/手機:
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機號,方便查詢和重復(fù)下載(系統(tǒng)自動生成)
支付方式: 支付寶    微信支付   
驗證碼:   換一換

 
賬號:
密碼:
驗證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會被瀏覽器默認(rèn)打開,此種情況可以點擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標(biāo)題沒有明確說明有答案則都視為沒有答案,請知曉。

Java程序設(shè)計實驗報告實驗報告冊.doc

學(xué) 生 實 驗 報 告 冊(理工類)課程名稱: Java程序設(shè)計實驗 專業(yè)班級: 12計算機科學(xué)與技術(shù)(1) 學(xué)生學(xué)號: 學(xué)生姓名: 所屬院部: 計算機工程學(xué)院 指導(dǎo)教師: 馬青霞 2014 2015學(xué)年 第 2 學(xué)期 金陵科技學(xué)院教務(wù)處制金陵科技學(xué)院實驗報告實驗項目名稱: Java編程基礎(chǔ) 實驗學(xué)時: 4 同組學(xué)生姓名: 無 實驗地點: A101 實驗日期: 4月1日-4月8日 實驗成績: 批改教師: 馬青霞 批改時間: 實驗1 JAVA編程基礎(chǔ)一、 實驗?zāi)康?、 熟練掌握J(rèn)DK編寫調(diào)試Java應(yīng)用程序及Java小程序的方法;2、 熟練掌握J(rèn)ava應(yīng)用程序的結(jié)構(gòu);3、 了解Java語言的特點,基本語句、運算符及表達(dá)式的使用方法;4、 熟練掌握常見數(shù)據(jù)類型的使用;5、熟練掌握if-else、switch、while、do-while、for、continue、break、return語句的使用方法;6、熟練掌握數(shù)組和字符串的使用。二、實驗要求1、編寫程序要規(guī)范、正確,上機調(diào)試過程和結(jié)果要有記錄;2、做完實驗后給出本實驗的實驗報告。三、實驗設(shè)備、環(huán)境安裝有JDK、Eclipse軟件的計算機。四、實驗步驟 采用記事本編寫一個簡單的應(yīng)用程序(1)新建一個記事本文件,重新命名為Hello.java(2)打開記事本,輸入以下內(nèi)容(注意大小寫):public class Hellopublic static void main(String args)System.out.println(hello hello);(3)請記錄程序編譯和執(zhí)行的步驟,并附上運行結(jié)果圖。 進入文件所在目錄cd classjavajava_ex1 編譯N:classjavajava_ex1javac Hello.java運行java Hello結(jié)果:五、實驗內(nèi)容1、從鍵盤上輸入學(xué)號、班級和姓名,并附上運行結(jié)果圖。import java.util.Scanner;public class KeyboardDemo public static void main(String args) Scanner scan = new Scanner(System.in);System.out.print(請輸入班級:);String cls = scan.nextLine();System.out.print(請輸入姓名:);String name = scan.nextLine();System.out.print(請輸入學(xué)號:);String num = scan.nextLine();System.out.println(班級:+cls+ 姓名:+name+ 學(xué)號+num);2、編寫一個程序,用來判斷輸入的是大寫字母,小寫字母,數(shù)字還是其他的字符(if)。import java.util.Scanner;public class CharDemo public static void main(String args) / TODO Auto-generated method stubScanner scan = new Scanner(System.in);while(true)System.out.print(請輸入一個字符:);char ch = scan.nextLine().charAt(0);if(Character.isUpperCase(ch)System.out.println(該字符是大寫字母:+ch);else if(Character.isLowerCase(ch)System.out.println(該字符是小寫字母:+ch);else if(Character.isDigit(ch)System.out.println(該字符是數(shù)字:+ch);else System.out.println(該字符是其他字符!); 3、編寫一個程序,實現(xiàn)簡單加、減、乘除的運算,要求從鍵盤上輸入數(shù)據(jù)(switch)。import java.util.Scanner;public class Count public static void main(String args) / TODO Auto-generated method stubint num1;int num2;char fh;Scanner sc = new Scanner(System.in);while(true)System.out.println(請輸入第一個數(shù):);num1 = sc.nextInt();System.out.println(請輸入您的運算符:);fh = sc.next().charAt(0);System.out.println(請輸入第二個數(shù):);num2 = sc.nextInt();switch(fh)case +:System.out.println(num1+num2=+(num1+num2);break;case -:System.out.println(num1-num2=+(num1-num2);break;case *:System.out.println(num1*num2=+(num1*num2);break;case /:if(num2=0)break;elseSystem.out.println(num1/num2=+(num1/num2);break;default:System.out.println(輸入有誤!);break;4、定義一個一維數(shù)組,通過鍵盤輸入10個兩位整數(shù),并求出其中的最大值和平均值,把結(jié)果顯示出來。import java.util.Scanner;public class ArrayDemo public static void main(String args) / TODO Auto-generated method stubScanner scan = new Scanner(System.in);int arr = new int10;int sum = 0;System.out.print(請輸入10個兩位整數(shù):);for(int i=0;i10;i+)arri=scan.nextInt();sum += arri;System.out.println(sum:+String.format(%d, sum);System.out.println(average:+String.format(%.2f, (double)sum/10);5、定義一個5行5列二維數(shù)組,用隨機數(shù)給二維數(shù)組賦值,按照5行5列的格式顯示出二維數(shù)組的內(nèi)容,把最大值顯示出來。public class Array5_5Demo public static void main(String args) / TODO Auto-generated method stubint arr = new int55;for(int i=0;i5;i+)for(int j=0;j5;j+)arrij = (int)(Math.random()*90+10);for(int i=0;i5;i+)for(int j=0;j5;j+)System.out.print(String.format(%4d, arrij);System.out.println();6、實現(xiàn)不規(guī)則二維數(shù)組的輸入和輸出。import java.util.Scanner;public class NoRuleArrDemo public static void main(String args) / TODO Auto-generated method stubint arr = new int3;arr0 = new int3;arr1 = new int2;arr2 = new int4;Scanner scan = new Scanner(System.in);for(int i=0;iarr.length;i+)for(int j=0;jarri.length;j+)System.out.print(請輸入數(shù)據(jù)(0-10000):);arrij = scan.nextInt();System.out.println(數(shù)組元素為:);for(int i=0;iarr.length;i+)for(int j=0;j10&age50)return true;return false;void show()System.out.println(學(xué)號:+num+n姓名:+name+n性別:+sex+n年齡:+age);public class demo1 public static void main(String args) / TODO Auto-generated method stubStudents stu = new Students(1205104006,wjw,f,21);if(stu.judgeAge()&stu.judgeSex()stu.show();elseSystem.out.println(學(xué)生初始化信息有誤,請重新輸入!);2、定義一個方法,用數(shù)組作為參數(shù)來傳遞數(shù)據(jù)(請補充下面的代碼)。package test1;import java.util.Arrays;public class demo1 public static void main(String args) int a=10,20,15,40,50,35;Myclass myclass=new Myclass();System.out.println(排序前:); myclass.printArr(a);Arrays.sort(a);System.out.println(排序后);myclass.printArr(a);class Myclass/定義一個方法,實現(xiàn)數(shù)組內(nèi)容的輸出void printArr(int arr)for(int i=0;iarr.length;i+)System.out.print(String.format(%4d,arri);System.out.println();3、 定義一個學(xué)生類,把學(xué)生類當(dāng)作對象來傳遞或者用對象數(shù)組作為參數(shù)傳遞。package test1;class Studentsprivate String num;private String name;private char sex;private int age;Students(String num,String name,char sex,int age)this.num = num;this.name = name;this.sex = sex;this.age = age;void show()System.out.println(學(xué)號:+num+n姓名:+name+n性別:+sex+n年齡:+age);public class demo2 public static void main(String args) Students stu= new Students2 ;stu0= new Students(1205104006,wjw,f,21);stu1= new Students(12051040,ys,m,22);print(stu); public static void print(Students stu) for(int i=0;istu.length;i+)System.out.println(第+(i+1)+個學(xué)生的信息:);stui.show();4、 利用方法的重載兩個整數(shù)和兩個雙精度類型數(shù)據(jù)求和。package test1;class Addpublic int Add(int num1,int num2)return num1+num2;public double Add(double num1,double num2)return num1+num2;public class demo3 public static void main(String args) int num1 = 10;int num2 = 20;double num3 = 10.23;double num4 = 30.74;Add add = new Add();System.out.println(int和:+num1+num2+=+add.Add(num1, num2);System.out.println(double整數(shù)和:+num3+num4+=+String.format(%.2f, add.Add(num3, num4);5、定義一個Area類,用構(gòu)造函數(shù)重載,實現(xiàn)矩形的面積,圓的面積,梯形的面積,定義一個ShowArea方法,顯示結(jié)果。package test1;class Areaprivate static final double PI = 3.14;private double area;Area(double width,double length)area = width*length;Area(double radius)area = PI*radius*radius;Area(double length1,double length2,double height)area = (length1+length2)*height/2;public void showArea()System.out.println(String.format(%.2f, area);public class AreaDemo public static void main(String args) Area rectangle = new Area(3.0,5.5);Area cycle = new Area(2.4);Area echelon = new Area(3.2,4.5,4);System.out.print(rectangle area:);rectangle.showArea();System.out.print(cycle area:);cycle.showArea();System.out.print(echelon area:);echelon.showArea();6、在該程序中構(gòu)造一個Person基類,在Person類的基礎(chǔ)上再構(gòu)造Student類,實現(xiàn)方法的覆蓋。class Personprivate int age;private String name;Person(String name,int age)this.name = name;this.age = age;void show()System.out.println(name:+name+nage:+age);void method()System.out.println(method調(diào)用);class Student extends PersonStudent(String name, int age) super(name, age);void method()System.out.println(method調(diào)用.study.);public class ExtendDemo public static void main(String args) Student stu = new Student(wjw,21);stu.show();stu.method();7、用面向?qū)ο蟮闹R,實現(xiàn)實驗一的計算器程序。package htp;import java.util.Scanner;class Operationprivate int num1;private int num2;char opt ;public int getNum1() return num1;public void setNum1(int num1) this.num1 = num1;public int getNume2() return num2;public void setNume2(int nume2) this.num2 = num2;public char getOpt() return opt;public void setOpt(char opt) this.opt = opt;Operation(int num1,char opt,int num2)this.num1 = num1;this.num2 = num2;this.opt = opt;public void Cal()switch(opt)case +:System.out.println(num1+num2=+(num1+num2);break;case -:System.out.println(num1-num2=+(num1-num2);break;case *:System.out.println(num1*num2=+(num1*num2);break;case /:if(num2=0)break;elseSystem.out.println(num1/num2=+(num1/num2);break;default:System.out.println(輸入有誤!);break;public class Calculate public static void main(String args) / TODO Auto-generated method stubScanner scan = new Scanner(System.in);int num1;int num2;char operator;System.out.println(請輸入第一個數(shù):);num1 = scan.nextInt();System.out.println(請輸入您的運算符:);operator = scan.next().charAt(0);System.out.println(請輸入第二個數(shù):);num2 = scan.nextInt();Operation op = new Operation(num1,operator,num2);op.Cal();靜態(tài)工廠(以加法為例):/*Test.java*/package cal;import java.util.Scanner;public class Test public static void main(String args) throws Exception Scanner input=new Scanner(System.in);System.out.print(請輸入第一個數(shù)據(jù):);int numA=input.nextInt();System.out.print(請輸入操作符:(+、-、*、/ );String type=input.next();System.out.print(請輸入第二個數(shù)據(jù):);int numB=input.nextInt();Factory factory=FactoryOperation.createFactory(type);Operation operation=factory.createOperation(); operation.setNumA(numA); operation.setNumB(numB); System.out.println(計算結(jié)果為:+operation.getResult();/* Operation.java */package cal;public abstract class Operation protected int numA,numB; public int getNumA() return numA;public void setNumA(int numA) this.numA = numA;public int getNumB() return numB;public void setNumB(int numB) this.numB = numB;public abstract double getResult();/* Factory .java*/package cal;public abstract class Factory public abstract Operation createOperation();/* FactoryOperation .java*/package cal;import java.io.File;import java.io.FileInputStream;import java.util.Properties;public class FactoryOperation public static Factory createFactory(String type) throws ExceptionProperties properties=new Properties();File file=new File(config.xml);properties.loadFromXML(new FileInputStream(file);String className= properties.getProperty(type);Class c=Class.forName(className);Factory factory=(Factory) (c.getClassLoader().loadClass(className).newInstance(); return factory;/*config.xml*/ calc.demo2.FactoryAdd /*OperationAdd .java*/package cal;public class OperationAdd extends OperationOverridepublic double getResult() return numA+numB;8、定義一個Icar和Icarcolor的接口,在接口Icar中定義一個Run方法和一個Stop方法,在接口Icarcolor中定義一個Color的屬性,再定義一個Car類實現(xiàn)接口中的方法和屬性。interface Icarpublic void run();public void stop();interface IcarColor final String color = purple;class Car implements Icar, IcarColorpublic void run()System.out.println(color+ Car running.);public void stop()System.out.println(color+ Car stop.);public class CarInterface public static void main(String args) / TODO Auto-generated method stubCar myCar = new Car();myCar.run();myCar.stop();實驗項目名稱: 圖形用戶界面 實驗學(xué)時: 6 同組學(xué)生姓名: 無 實驗地點: A101 實驗日期: 5月13日-5月27日 實驗成績: 批改教師: 馬青霞 批改時間: 實驗3 圖形用戶界面一、 實驗?zāi)康?、要?、 掌握Swing組件的使用方法;2、 熟練掌握Swing中常用布局管理器的使用方法;3、 掌握用戶界面動作與事件的處理程序的編寫方法;4、 熟練掌握構(gòu)造用戶界面的方法和常見界面元素的使用;5、熟練掌握J(rèn)ava繪圖的主要方法。二、實驗要求1、編寫程序要規(guī)范、正確,上機調(diào)試過程和結(jié)果要有記錄;2、做完實驗后給出本實驗的實驗報告。三、實驗設(shè)備、環(huán)境安裝有JDK、Eclipse軟件的計算機。四、實驗內(nèi)容1、設(shè)計一個Windows應(yīng)用程序,在該程序中首先構(gòu)造一個學(xué)生基本類,再分別構(gòu)造小學(xué)生、中學(xué)生、大學(xué)生派生類,當(dāng)輸入相關(guān)數(shù)據(jù),單擊不同的按鈕時,將分別創(chuàng)建不同的學(xué)生類對象,并輸出當(dāng)前學(xué)生的總?cè)藬?shù),該學(xué)生的姓名,學(xué)生類型,平均成績。程序要求:(1)每個學(xué)生都有的字段為姓名、年齡。(2)小學(xué)生的字段還有語文,數(shù)學(xué),用來表示這兩科的成績。(3)中學(xué)生在此基礎(chǔ)上增加英語成績。(4)大學(xué)生分為必修課和選修課兩項成績。(5)學(xué)生類提供方法來統(tǒng)計自己的總成績并輸出。(6)通過靜態(tài)成員自動記錄學(xué)生總?cè)藬?shù)。(7)成員初始化通過構(gòu)造函數(shù)完成。/*學(xué)生類*/package htp.gui;public abstract class Student private String name;private int age;double average;static int num;public Student(String name,int age)this.name = name;this.age = age;public abstract double getAverage();class StuPri extends Studentprivate double chinese;private double math;public StuPri(String name, int age, double chinese, double math) super(name, age);this.chinese = chinese;this.math = math;Overridepublic double getAverage()average = (chinese + math)/2;return average;class StuSec extends Studentprivate double chinese;private double math;private double english;public StuSec(String name, int age, double chinese, double math, double english) super(name, age);this.chinese = chinese;this.math = math;this.english = english;Overridepublic double getAverage() average = (chinese + math + english)/3;return average;class StuColl extends Studentprivate double optional;private double comp;public StuColl(String name, int age, double optional, double comp) super(name, age);this.optional = optional;p = comp;Overridepublic double getAverage()average = (optional + comp)/2;return average;/*界面*/package htp.gui;import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class StudentGui extends JFrame implements ActionListenerJPanel jp1,jp2;JPanel jp1_1,jp1_2,jp1_3;JButton jb_pri,jb_sec,jb_col;JLabel jl_name,jl_age,jl_ch_op,jl_math_com,jl_en;JTextField jtf_name,jtf_age;JTextField jtfCh_Opt,jtfMath_Com,jtfEn;JTextArea jta;public static void main(String args) StudentGui stu = new StudentGui();public StudentGui()jp1 = new JPanel();jp2 = new JPanel();jp1_1 = new JPanel();jp1_2 = new JPanel();jp1_3 = new JPanel();jl_name = new JLabel(姓名);jl_age = new JLabel(年齡);jl_ch_op = new JLabel(語文/選修);jl_math_com = new JLabel(數(shù)學(xué)/必修);jl_en = new JLabel(英語);jtf_name = new JTextField(10);jtf_age = new JTextField(10);jtfCh_Opt = new JTextField(10);jtfMath_Com = new JTextField(10);jtfEn = new JTextField(10);jta = new JTextArea(30,20);jb_pri = new JButton(小學(xué)生);jb_pri.addActionListener(this);jb_sec = new JButton(中學(xué)生);jb_sec.addActionListener(this);jb_col = new JButton(大學(xué)生);jb_col.addActionListener(this);jp1.setLayout(new GridLayout(3,1);jp1_1.add(jl_name);jp1_1.add(jtf_name);jp1_1.add(jl_ch_op);jp1_1.add(jtfCh_Opt);jp1_1.add(jb_pri);jp1_2.add(jl_age);jp1_2.add(jtf_age);jp1_2.add(jl_math_com);jp1_2.add(jtfMath_Com);jp1_2.add(jb_sec);jp1_3.setLayout(new FlowLayout(FlowLayout.RIGHT);jp1_3.add(jl_en,Right);jp1_3.add(jtfEn,East);jp1_3.add(jb_col,East);jp1.add(jp1_1,North);jp1.add(jp1_2,Center);jp1.add(jp1_3,South);jp2.add(jta);this.add(jp1,North);this.add(jp2);this.setVisible(true);this.setTitle(學(xué)生信息);this.setSize(430,500);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Overridepublic void actionPerformed(ActionEvent e) String name;int age;double chi_opt,math_comp,en;double average = 0;name = jtf_name.getText();age = Integer.parseInt(jtf_age.getText();chi_opt = Double.parseDouble(jtfCh_Opt.getText();math_comp = Double.parseDouble(jtfMath_Com.getText();if(e.getSource()=jb_pri)StuPri stuPri = new StuPri(name, age, chi_opt, math_comp);average = stuPri.getAverage();else if(e.getSource()=jb_sec)en = Double.parseDouble(jtfEn.getText();StuSec stuSec = new StuSec(name, age, chi_opt, math_comp, en);average = stuSec.getAverage();else if(e.getSource()=jb_col)StuColl stuColl = new StuColl(name, age, chi_opt, math_comp);average = stuColl.getAverage();Student.num +;String result = 學(xué)生總?cè)藬?shù): + Student.num +;當(dāng)前學(xué)生平均成績:+ String.format(%.2f, average);jta.setText( result );2、在該程序中定義平面圖形抽象類Figure和派生類圓(Circle)、矩形(Rectangle)和三角形(Triangle)。該程序?qū)崿F(xiàn)的功能包括:輸入相應(yīng)圖形的參數(shù),如矩形的長和寬,單擊相應(yīng)的按鈕,根據(jù)輸入?yún)?shù)創(chuàng)建圖形類并輸出該對象的面積。/*圖形類*/package htp.test; abstract class Figurepublic abstract double getArea();class Circle extends Figureprivate static final double PI = 3.1415926;private double radius;Circle(double radius)this.radius = radius;Overridepublic double getArea() return radius*radius*PI;class Rectangle extends Figureprivate double width;private double length;Rectangle(double width,double length)this.width = width;this.length = length;Overridepublic double getArea() return width*length;class Triangle extends Figureprivate double height;private double length;Triangle(double height,double length)this.height = height;this.length = length;Overridepublic double getArea() return height*length/2;/*圖形界面*/package htp.test;import java.awt.event.*;import javax.swing.*;import java.awt.*;public class Demo extends JFrame implements ActionListenerJLabel jlRadius,jlLength,jlWidth_H

注意事項

本文(Java程序設(shè)計實驗報告實驗報告冊.doc)為本站會員(good****022)主動上傳,裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng)(點擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因為網(wǎng)速或其他原因下載失敗請重新下載,重復(fù)下載不扣分。




關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!