Java (5) 1 Lesson 3: x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java , 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flow

Similar documents
Java (7) Lesson = (1) 1 m 3 /s m 2 5 m 2 4 m 2 1 m 3 m 1 m 0.5 m 3 /ms 0.3 m 3 /ms 0.6 m 3 /ms 1 1 3

: : : TSTank 2

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

新・明解Java入門

Microsoft Word - keisankigairon.ch doc

untitled

3 Java 3.1 Hello World! Hello World public class HelloWorld { public static void main(string[] args) { System.out.println("Hello World");

ALG ppt

VB.NETコーディング標準

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

K227 Java 2

JAVA とテンプレート

text_08.dvi

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

Java updated

ALG ppt

Java演習(2) -- 簡単なプログラム --

Microsoft PowerPoint ppt

r1.dvi

10K pdf

文字列操作と正規表現


Thread

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

PowerPoint Presentation

Program Design (プログラム設計)

1

r02.dvi

ohp02.dvi

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

6-1

8 if switch for while do while 2

226


Quick Sort 計算機アルゴリズム特論 :2017 年度 只木進一

Exam : 1z1-809-JPN Title : Java SE 8 Programmer II Vendor : Oracle Version : DEMO Get Latest & Valid 1z1-809-JPN Exam's Question and Answers 1 from Ac

デジタル表現論・第4回

untitled

オブジェクト脳のつくり方

明解Javaによるアルゴリズムとデータ構造

明解Javaによるアルゴリズムとデータ構造

oop1

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1) int boolean switch case C Calendar java.util.calendar A

ex01.dvi

untitled

I java A

TopLink å SampleClient.java... 5 Ò readallsample() querysample() cachesample() Ç..

tkk0408nari

ALG2012-A.ppt

新・明解Javaで学ぶアルゴリズムとデータ構造

2.2 Java C main Java main 2 C 6 C Java 3 C Java ( ) G101Hello.java G101Hello main G101Hello.java /* G101Hello */ class G101Hello { /* main */ public s

目的 泡立ち法を例に Comparableインターフェイスの実装 抽象クラスの利用 型パラメタの利用 比較 入替 の回数を計測

ALG2012-F.ppt

Prog2_9th

java_servlet2_見本

Java プログラミング Ⅰ 3 回目変数 変数 変 数 一時的に値を記憶させておく機能型 ( データ型 ) と識別子をもつ 2 型 ( データ型 ) 変数の種類型に応じて記憶できる値の種類や範囲が決まる 型 値の種類 値の範囲 boolean 真偽値 true / false char 2バイト文

,,,,., C Java,,.,,.,., ,,.,, i

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

Microsoft PowerPoint - ●SWIM_ _INET掲載用.pptx

JavaプログラミングⅠ

アルゴリズムとデータ構造1

10K

Java演習(4) -- 変数と型 --

2

問題1 以下に示すプログラムは、次の処理をするプログラムである

プログラミングA

アルゴリズムとデータ構造1

明解Java入門編

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

1. はじめに 二分木ヒープ 様々なアルゴリズムにおいて ある要素の集合またはリストから 最小 な要素を取り 出す必要がある そのような場合に使われる標準的データ構造が二分木ヒープ (binary heap) である あるオブジェクトO を考える そのオブジェクトは ラベル O. label と値

(Basic Theory of Information Processing) 1

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

ex01.dvi

2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible

(Java/FX ) Java CD Java version Java VC++ Python Ruby Java Java Eclipse Java Java 3 Java for Everyone 2 10 Java Midi Java JavaFX Shape Canvas C

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap

Javaセキュアコーディングセミナー2013東京第1回 演習の解説

目 次 Java GUI 3 1 概要 クラス構成 ソースコード例 課題...7 i

1.ppt

JavaプログラミングⅠ

解きながら学ぶJava入門編

新・明解Javaで学ぶアルゴリズムとデータ構造

Java学習教材

JavaプログラミングⅠ

とても使いやすい Boost の serialization

double 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( "data.t

2. データ構造ヒープに保存するデータは 番号付けられて保存される 従って リスト L として保存することとする 3. アルゴリズム 3.1. 要素の追加新しい要素の追加は リストの終端に置くことで開始する つまり 最下層の一番右 または新たに最下層を生成してその一番左となる この後 この要素を正し

JavaプログラミングⅠ

Microsoft PowerPoint - prog03.ppt

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

P R O F I L E

** 平成 16 年度 FE 午後問題 Java** 示現塾プロジェクトマネージャ テクニカルエンジニア ( ネットワーク ) など各種セミナーを開催中!! 開催日 受講料 カリキュラム等 詳しくは 今すぐアクセス!! 平成 16

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

シミュレーションの簡単な例 GUI 無しのシミュレーションを作る GUI を作る パラメタを設定するデモンストレーションをする 2 オブジェクト指向プログラミング特論


Javaセキュアコーディングセミナー東京 第3回 入出力(File, Stream)と例外時の動作 演習解説

Transcription:

Java (5) 1 Lesson 3: 2008-05-20 2 x 2 +4x +5 f(x) =x 2 +4x +5 x f(10) x Java 1.1 10 10 0 1.0 2.0, 3.0,..., 10.0, 1.0, 2.0,... flow rate (m**3/s) "flowrate.dat" 10 8 6 4 2 0 0 5 10 15 20 25 time (s) 1 1

flow[0] = 1.0,..., flow[9] = 10.0 10 time time 10 0, 1, 2,..., 9, 0, 1, flow[(int)time 10 ] flow[20] = flow[0] = 1.0 int index = (int) time % flow.length; // flow[index] % f(x) x TankCalculator3.java 7-14 24-25 getflow report 2

1.2 TankCalculator3.java 1: public class TankCalculator3 { 2: final double TANK_AREA = 20.0; //20.0 m**2 3: final double INITIAL_TANK_LEVEL = 10.0; //10.0 m 4: double flow[] 5: = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; //m**3/s 6: 7: public double getflow(double t) { 8: int index = (int)t % flow.length; 9: return flow[index]; 10: } 11: 12: public void report(double time, double flow, double tanklevel) { 13: System.out.println(time + ", " + flow + ", " + tanklevel); 14: } 15: 16: public static void main(string args[]) { 17: TankCalculator3 calculator = new TankCalculator3(); 18: final int MAX_TIME = 50; 19: double tanklevel[] = new double[max_time+1]; //m 20: tanklevel[0] = calculator.initial_tank_level; 3

21: System.out.println("Time(s), Flow(m**3/s), Tank Level(m)"); 22: for (int i = 0; i< MAX_TIME; i++) { 23: double time = i; 24: tanklevel[i+1] = tanklevel[i] + calculator.getflow(time)/calculator.tank_area; 25: calculator.report(time, calculator.getflow(time), tanklevel[i]); 26: } 27: double finaltime = MAX_TIME; 28: calculator.report(finaltime, 0.0, tanklevel[max_time]); 29: } 30: } 2 5 7 10 getflow() 12 14 (time) (flow) (tanklevel) report() 16 29 main() 4

17 TankCalculator3 new calculator calculator TankCalculator3 20,24,25,28 calculator. calculator. 5

1.3 Java C++ (object) 1 (class) new 1 C C 2 6

7

1.4 () 2 = new (); 17: TankCalculator3 calculator = new TankCalculator3(); 1. calculator 2. TankCalculator3 3. calculator 3 TankCalculator3.java TANK_AREA, INITIAL_TANK_LEVEL, flow[] 3 2 3 calculator.tank AREA, calculator.report(...) 8

1.5 java TankCalculator3 getflow() report() 1.5.1 class (,... ) { } 7: public double getflow(double t) { 8: int index = (int)t % flow.length; 9: return flow[index]; 10: } public private public private 9

static Lesson dynamic static void 4 java return return 4 main() 10

1.5.2 int double 5 5 11

1.6 java 3 1. /* */ 2. // 3. /** */ 3. 1. javadoc tanklevel = INITIAL_TANK_LEVEL + FLOW_RATE * time / TANK_AREA; tl = ITL + FR * t / TA; // 12

6 java 6 // set settime, get getflow, is isalive, has haschild 13

1.7 Javadoc Java javadoc 7 javadoc 7 Java web html /**, */ @param @return @ javadoc TankCalculator4.java javadoc -d docs TankCalculator4.java -d docs html docs TankCalculator4.html web 14

Javadoc TankCalculator4.java 1: /** 2: * 3: * @author 4: * @version 3.0 5: */ 6: public class TankCalculator4 { 7: /** 8: * m**2 9: */ 10: final double TANK_AREA = 20.0; 11: /** 12: * m 13: */ 14: final double INITIAL_TANK_LEVEL = 10.0; //10.0 m 15: /** 16: * m**3/s 17: */ 18: double flow[] 19: = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; //m**3/s 20: 15

21: /** 22: (m**3/s) 23: @param t 24: @return mm*3/s 25: */ 26: public double getflow(double t) { 27: int index = (int)t % flow.length; 28: return flow[index]; 29: } 30: 31: /** 32: 33: @param time 34: @param flow 35: @param tanklevel 36: */ 37: public void report(double time, double flow, double tanklevel) { 38: System.out.println(time + ", " + flow + ", " + tanklevel); 39: } 40: 41: public static void main(string args[]) { 16

42: TankCalculator4 tankcalculator = new TankCalculator(); 43: final int TIME_HORIZON = 100; 44: double tanklevel[] = new double[time_horizon+1]; //m 45: tanklevel[0] = tankcalculator.initial_tank_level; 46: System.out.println("Time(s), Flow(m**3/s), Tank Level(m)"); 47: for (int i = 0; i< TIME_HORIZON; i++) { 48: double time = i; 49: tanklevel[i+1] = tanklevel[i] + tankcalculator.getflow(time)/tankcalculator.tank_area; 50: tankcalculator.report(time, tankcalculator.getflow(time), tanklevel[i]); 51: } 52: double finaltime = TIME_HORIZON; 53: tankcalculator.report(finaltime, 0.0, tanklevel[time_horizon]); 54: } // End of main() method. 55: } // End of class TankCalculator4 javadoc M: java docs TankCalculator4.html 17

4 javadoc 18

while, for, if { }. javadoc HTML 19