From 1723030395e9789e6a19e340d407ee53ceec4512 Mon Sep 17 00:00:00 2001 From: jiang Date: Wed, 21 Oct 2020 19:14:58 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=80=9C=E2=80=9C=E2=80=9C20201021?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework/counts.java | 30 ++++++++++++++++++++++++++++++ homework/printMatrix.java | 23 +++++++++++++++++++++++ homework/reverse.java | 24 ++++++++++++++++++++++++ homework/sumMatrix.java | 31 +++++++++++++++++++++++++++++++ homework/temp.java | 30 ++++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 homework/counts.java create mode 100644 homework/printMatrix.java create mode 100644 homework/reverse.java create mode 100644 homework/sumMatrix.java create mode 100644 homework/temp.java diff --git a/homework/counts.java b/homework/counts.java new file mode 100644 index 0000000..ba5ec06 --- /dev/null +++ b/homework/counts.java @@ -0,0 +1,30 @@ +public class counts{ + public static void main(String[] args){ + int [] numbers = new int[100]; + int [] counts = new int[10]; + + for(int i = 0; i 0){ + a = number % 10; + number = number/ 10; + System.out.print( a ); + } + + } + + } +} diff --git a/homework/sumMatrix.java b/homework/sumMatrix.java new file mode 100644 index 0000000..ab18bec --- /dev/null +++ b/homework/sumMatrix.java @@ -0,0 +1,31 @@ +import java.util.Scanner; +public class sumMatrix{ +public static void main(String[] args){ + System.out.println("import:"); + Scanner scan = new Scanner(System.in); + int n = scan.nextInt(); + double[][] matrix = new double[n][n]; + for(int i = 0;i Date: Thu, 5 Nov 2020 11:28:53 +0800 Subject: [PATCH 2/3] 1105 --- homework1105/Account.java | 73 +++++++++++++++++++++++++++++++++++++ homework1105/arraysort.java | 39 ++++++++++++++++++++ homework1105/clone.java | 57 +++++++++++++++++++++++++++++ homework1105/testdate.java | 13 +++++++ 4 files changed, 182 insertions(+) create mode 100644 homework1105/Account.java create mode 100644 homework1105/arraysort.java create mode 100644 homework1105/clone.java create mode 100644 homework1105/testdate.java diff --git a/homework1105/Account.java b/homework1105/Account.java new file mode 100644 index 0000000..af264b4 --- /dev/null +++ b/homework1105/Account.java @@ -0,0 +1,73 @@ +import java.util.Date; + public class Account{ + +public static void main(String[] args){ + Account account = new Account(1,20000); + account.setannualInterestRate (4.5); + account.Withdrawl(2000); + account.Deposit(2000); + + System.out.println("blance:" + account.getbalance() + "\n interest:"+account.getMonthlyInterest()+"\ndate" +account.getdateCreated() ); + +} + private int id=0; + private double balance=0; + private double annualInterestRate = 0; + private Date dateCreated; + public Account(){ + this.dateCreated = new Date(); +}//创建默认账户的无参构造方法 + public Account(int id, double balance){ +//创建指定id与初始余额账户的构造方法 + this.id = id; + this. balance = balance; + this.dateCreated = new Date(); + } +//访问器以及修改器 + public int getid(){ + return id; + } + public void setid(int newid){ + this.id = newid; + } + public double getbalance(){ + return balance; + } + public void setbalance(double newbalance){ + this.balance = newbalance; + } +public double getannualInterestRate(){ + return annualInterestRate; + } + public void setannualInterestRate(double annualInterestRate){ + this.annualInterestRate = annualInterestRate; + } +//dateCreated的访问器方法 + public Date getdateCreated(){ + return dateCreated; +} + public double getMonthlyInterestRate(){ + double i = annualInterestRate/12; + return i; +} + public double getMonthlyInterest(){ + double i = balance *(annualInterestRate/12)/100; + return i ; + + } + +public void Withdrawl(double money){ + if(money > balance) + balance = balance - money; +else + System.out.println("you donnot have enough money"); +} +public void Deposit(double money){ + balance += money; +} + + + + + +} \ No newline at end of file diff --git a/homework1105/arraysort.java b/homework1105/arraysort.java new file mode 100644 index 0000000..54f3327 --- /dev/null +++ b/homework1105/arraysort.java @@ -0,0 +1,39 @@ +import java.util.ArrayList; +import java.math.*; +public class arraysort{ + public static void main(String[] args){ + ArrayList list = new ArrayList<>(); + list.add(3); + list.add(9); + list.add(5); + list.add(7); + list.add(1); + sort(list); + +} + +public static void sort(ArrayListlist){ + for(int i = 0;i < list.size();i++){ + Number min = list.get(i); + int minindex = i; + + for(int j = i+1;j list.get(j).intValue()){ + min = list.get(j); + minindex = j; + } + } + + if(minindex != i){ + list.set(minindex,list.get(i)); + list.set(i,min); + } + + } + for (int a =0; a < list.size();a++){ + System.out.print(list.get(a) + ""); + } +} + + +} \ No newline at end of file diff --git a/homework1105/clone.java b/homework1105/clone.java new file mode 100644 index 0000000..46d4cda --- /dev/null +++ b/homework1105/clone.java @@ -0,0 +1,57 @@ +import java.util.ArrayList; +import java.math.*; +public class clone{ +public static void main(String[] args){ + courseclone course1 = new courseclone("data structures"); + courseclone course2 = (courseclone) course1.clone(); + course1.addStudent("S1"); + course1.addStudent("S2"); + course1.addStudent("S3"); + course2.addStudent("S4"); + course2.addStudent("S5"); + System.out.println(course1.getNumberOfStudents()); + System.out.println(course2.getNumberOfStudents()); + +} +} + class courseclone implements Cloneable{ + private String courseName; + private String[] students = new String[100]; + private int numberOfStudents; + + public courseclone(String courseName){ + this.courseName = courseName; + } + public void addStudent(String student){ + students[numberOfStudents] = student; + numberOfStudents++; + } + public String[] getStudents(){ + return students; + } + public int getNumberOfStudents(){ + return numberOfStudents; + } + public String getCourseName(){ + return courseName; + } + +@Override +public Object clone(){ + try{ + courseclone c = (courseclone)super.clone(); + c.students = new String[100]; + + + return c; + + }catch(CloneNotSupportedException ex){ + return null; + } +} + +} + + + + diff --git a/homework1105/testdate.java b/homework1105/testdate.java new file mode 100644 index 0000000..1b0a47c --- /dev/null +++ b/homework1105/testdate.java @@ -0,0 +1,13 @@ +import java.util.Date; +public class testdate{ + public static void main(String[] args){ + long time = 10000; + Date date = new Date(time); + + for(int i = 0;i<7;i++){ + time = time* 10; + date.setTime(time); + System.out.println("when the elapsetime is:"+ time + "the date is: " + date.toString()); + } + } +} \ No newline at end of file From 0d459a10805fe18413df00b09bfc1f798d65e25e Mon Sep 17 00:00:00 2001 From: jiang Date: Fri, 13 Nov 2020 21:20:13 +0800 Subject: [PATCH 3/3] homework1113 --- homework1113/hashtest1.java | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 homework1113/hashtest1.java diff --git a/homework1113/hashtest1.java b/homework1113/hashtest1.java new file mode 100644 index 0000000..e442a79 --- /dev/null +++ b/homework1113/hashtest1.java @@ -0,0 +1,71 @@ +import java.io.InputStream; +import java.io.File; +import java.io.FileInputStream; +import java.security.MessageDigest; +import java.io.FileNotFoundException; +public class hashtest1{ + public static void main(String[] args){ + try{ + String path = "G:\\java"; + byte[] sha1 = fileHash(path); + String code = ""; + for(int i = 0;i0){ + md.update(buffer,0,length); + + } + }while(length != -1); + fis.close(); + } + catch(Exception e){ + e.printStackTrace(); + } + + + } + if(fs[i].isDirectory()){ + System.out.println("Directory:"+fs[i].getName()); + fileHash(path + File.separator + fs[i].getName()); + } + }//for寰幆 + return md.digest(); + + } + catch(Exception e){ + e.printStackTrace(); + return null; + } + }//fileHash + + + +} \ No newline at end of file