JAVA 密码算法报告.docx
《JAVA 密码算法报告.docx》由会员分享,可在线阅读,更多相关《JAVA 密码算法报告.docx(10页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、Java暗号 目的本JAVA言語用、共通鍵暗号方式暗号化、復号作成最終目標。Java言語() 所要年数、総預金額計算(a) 課題毎年一定金額預、目標金額達上回年数時総預金額提示作成。(b) 作成public class Calculation public static void main(String args)int goal;int deposit;int amount = 0;int years = 0;try goal = Integer.parseInt(args0); System.out.println(目標金額:+goal+円); deposit = Integer.pars
2、eInt(args1); System.out.println(毎年預金額:+deposit+円); while(amount goal)amount += deposit;years+; System.out.println(所要年数:+years+年); System.out.println(総預金額:+amount+円);catch(Exception ex) ex.printStackTrace(); (c) 実行結果目標金額:10000円毎年総預金額:1500円所要年数:7年総預金額:10500円() 標準出力(a) 課題 文字列標準出力作成、後、自分名字字指定、実行。System.
3、out.println代System.out.print、System.out.write(buf)代System.out.write(buf,off,len)使用、StdOutSample.java結果同一StdOutPrac.java作成。、実行行、StdOutSample.jav同結果確認。、以下変数buf格納長(int型)、buf.length得。length。(b) StdOutSample実行結果String標準出力: roka配列標準出力: roka(c) 変更public class StdOutParc public static void main(String args)
4、String dataP;String dataW;byte buf = new byte100;try dataP = args0; System.out.print(String標準出力:+dataP+n); dataW = 配列標準出力:+args0+n; buf = dataW.getBytes(); System.out.write(buf, 0, buf.length);catch(Exception ex) ex.printStackTrace(); (d) StdOutPrac実行結果String標準出力:roka配列標準出力:roka例外処理()同一(a) 課題Excepti
5、on.java作成、後、以下三種類順次指定実行、結果記録。-1, 50, 100class ArgException extends Exceptionpublic class Except public static void main(String args)try total(Integer.parseInt(args0);catch(ArgException e) System.out.println(:+e); public static void total(int n) throws ArgExceptionint sum = 0;if(n 100)throw new ArgEx
6、ception();for(int i = 1; i = n; i+) sum += i;System.out.println(合計 = +sum); (b) 実行結果ArgException合計1275合計5050()異(a) 課題 上記以下部分分割、実行。作成Exception.java及含別配下行。(参考文献2)(b) 分割class ArgException extends Exceptionpublic class ExceptMain public static void main(String args)try ExceptSub.total(Integer.parseInt(a
7、rgs0);catch(ArgException e) System.out.println(:+e); public class ExceptSub public static void total(int n) throws ArgException int sum = 0; if(n 100)throw new ArgException(); for(int i = 1; i n; i+) sum += i;System.out.println(合計 = +sum); (c) 実行結果ArgException合計1275合計5050入出力処理()文字列入出力(a) 課題文字列入出力行Fi
8、leRW作成、実行。、入力(内容自由、日本語記述)作成。、入力文字数出力文字数関係記録、相違有無確認。更、相違場合、理由記述。(b) 実行結果入力文:大阪工業大学文字数合計:6入力文:大阪工業大学情報科学部文字数合計:12(c) 実行結果考察大阪工業大学一行6文字、大阪工業大学¥情報科学部複数行合計12文字。、改行加算、一文字増。()列入出力(a) 課題 FileInputStream、FileOutputStream使用(StreamRW.java)作成。但、FileRW.java文字数数置換。、読込出力(while内)System.out.write使用。、入力作成(文字列入出力使用使用)
9、。(b) 作成import java.io.*;public class StreamRW public static void main(String args)byte buff = new byte10;int length = 0;int totalLen = 0;try FileInputStream streamRd = new FileInputStream(args0); FileOutputStream streamWt = new FileOutputStream(args1); System.out.println(入力文:); while(length = stream
10、Rd.read(buff) != -1)totalLen = totalLen + length;streamWt.write(buff,0,length);System.out.write(buff,0,length); System.out.println(); System.out.println(数合計:+totalLen); streamRd.close(); streamWt.close();catch(Exception ex) ex.printStackTrace(); (c) 実行結果入力文:大阪工業大学情報科学部数合計:35()入出力(a) 課題 Struct入出力行以下(
11、ObjectIO.java)示箇所補、完成。、後、実行行。本Struct生成後、出力後、入力、入力実行。(b) 作成/Object: 文字列文字列長import java.io.*; public class Struct implements Serializableprivate String str;private int leng;public Struct(String str) this.str = str; this.leng = str.length();public void print() System.out.println(文字列:+str); System.out.p
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 密码算法报告 密码 算法 报告
限制150内