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

Similar documents
3 p.1 3 Java Java Java try catch C Java if for while C 3.1 boolean Java if C if ( ) 1 if ( ) 1 else , 2 { } boolean true false 2 boolean Gr

I 3 p.2 3 Java AddTime.java public class AddTime extends JApplet { int hour1, minute1, hour2, minute2; public void init() { hour1 = Integer.pars

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

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

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

I. (i) Foo public (A). javac Foo.java java Foo.class (C). javac Foo java Foo (ii)? (B). javac Foo.java java Foo (D). javac Foo java Foo.class (A). Jav

新・明解Java入門

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public

Java 2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q 2.

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

2 p.2 2 Java > javac Hello0.java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.j

2 p.2 2 Java Hello0.class JVM Hello0 java > java Hello0.class Hello World! javac Java JVM java JVM : Java > javac 2> Q Foo.java Java : Q B

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

:30 12:00 I. I V II. III. IV. ( a d) V. VI : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeyliste

K227 Java 2

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

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i

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;

r3.dvi

untitled

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi


< F2D89BA8EE882C E6A7464>

II Java :30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K

Thread

r2.dvi

: : : TSTank 2

入門Java解答.doc

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

8 if switch for while do while 2

r3.dvi

text_13.dvi

スライド 1

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

Microsoft Word - keisankigairon.ch doc

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

Microsoft PowerPoint - OOP.pptx

2

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

r14.dvi

< F2D A839382CC906A2E6A7464>

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

ohp02.dvi

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

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

Java updated

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

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

I. (i) Java? (A). Foo_Bar (B). G day (C). 999 (D). Golgo13 (ii)? (A). Java public (B). Java (C). Java JavaScript (D). Java C Java C (iii)? (A). Java (

I java A

< F2D82518E9F8AD CC834F CC8CFC82AB82C68D4C>

上達Java解答.doc

4 p.2 4 GUI return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mousee

r02.dvi

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra

< F2D82518E9F8AD CC95BD8D7388DA93AE2E6A7464>

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

AWT setcolor, drawstring Java AWT Abstract Window Toolkit Graphics AWT import import java.awt.* ; // AWT Graphics import java.awt.graphics; // AWT Gra

Java演習(6) -- 条件分岐 --

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

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

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

本サンプル問題の著作権は日本商工会議所に帰属します また 本サンプル問題の無断転載 無断営利利用を厳禁します 本サンプル問題の内容や解答等に関するお問 い合わせは 受け付けておりませんので ご了承ください 日商プログラミング検定 STANDARD(Java) サンプル問題 知識科目 第 1 問 (

< F2D834F838C A815B A CC>

10K pdf

ex01.dvi

Java学習教材

< F2D B838A835882CC8CF68EAE2E6A7464>

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

r6.dvi

任意の加算プログラム

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

(1) プログラムの開始場所はいつでも main( ) メソッドから始まる 順番に実行され add( a,b) が実行される これは メソッドを呼び出す ともいう (2)add( ) メソッドに実行が移る この際 add( ) メソッド呼び出し時の a と b の値がそれぞれ add( ) メソッド

r2.dvi

1.ppt

ALG ppt

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


C言語によるアルゴリズムとデータ構造

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

main

untitled

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

ex01.dvi

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

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

JAVA とテンプレート

PowerPoint Presentation

解きながら学ぶJava入門編

(Basic Theory of Information Processing) 1

text_08.dvi

< F2D82518CC282CC D2E6A7464>

(Microsoft PowerPoint - \223\306\217KJAVA\221\346\202R\224\ ppt)

r1.dvi

r4.dvi

Microsoft PowerPoint ppt

< F2D A838B838D96402E6A7464>

明解Java入門編

Transcription:

Java 3 p.1 3 Java Java if for while C 3.1 if Java if C if if ( ) 1 if ( ) 1 else 2 1 1 2 2 1, 2 { Q 3.1.1 1. int n = 2; if (n <= 1) { System.out.printf("A"); if (n <= 2) { System.out.printf("B"); if (n <= 3) { System.out.printf("C"); 2. : int n = 2; if (n <= 1) { System.out.printf("A"); else if (n <= 2) { System.out.printf("B"); else if (n <= 3) { System.out.printf("C");

Java 3 p.2 3 Java : boolean Graphics draw3drect fill3drect C int C OK while (1)... 3.1.2 int boolean switch case C 3.1.3 Calendar java.util.calendar API CalendarTest.java import javax.swing.*; import java.awt.*; import java.util.*; public class CalendarTest extends JPanel { public CalendarTest() { setpreferredsize(new Dimension(250, 100)); @Override public void paintcomponent(graphics g) { super.paintcomponent(g); Calendar now = Calendar.getInstance(); int day = now.get(calendar.day_of_week); int hour = now.get(calendar.hour_of_day); int min = now.get(calendar.minute); if (day == Calendar.SUNDAY) { g.setcolor(color.red); g.drawstring(" ", 30, 25); if (hour < 12) { g.drawstring(" ", 30, 75);

3.2. String Java 3 p.3 else if (hour < 18) { g.drawstring(" ", 30, 75); else { g.drawstring(" ", 30, 75); g.drawstring(" " + hour + " " + min + " ", 30, 50);... // main == if 3.2 String Java + 3.2.1 String String String String String : System.out.println("2 + 2 " + (2 + 2)); System.out.println(2 + "*" + 3 + " " + 2 * 3 + " "); JDK 5.0 C printf sprintf drawstring String.format g.drawstring(string.format(" %d %d ", hour, min), 30, 50); : printf Generics Autoboxing Varargs API public static String format(string format, Object... args)... format java.lang.string Q 3.2.1 1 + 1 2 1. System.out.println("1 + 1 + (1 + 1) + ") 2. System.out.println("1 + 1 " + (1 + 1) + " ")

Java 3 p.4 3 Java 3. System.out.println("1 + 1 " + 1 + 1 + " ") 4. System.out.println("1 + 1 "(1 + 1)" ") 5. System.out.printf("1 + 1 %d %n", 1 + 1) 6. System.out.println(String.format("1+1 %d ", 1+1)) 3.3 for, while, do while while ( 1 ) 1 for ( 1 ; 2 ; 3 ) 1 for ( : ) 1 do 1 while ( 1 ); for while while 1 1 1 for 1 2 1 3 2 for JDK5.0 for-each each Iterable : for do while C Q 3.3.1 int i; for (i = 0; i < 4; i++) { System.out.printf("*%d", i); System.out.printf(" %d", i); : 3.3.2 n N gon.java import javax.swing.*; import java.awt.*; import static java.lang.math.*; public class N_gon extends JPanel {

3.3. for, while, do while Java 3 p.5 public N_gon() { setpreferredsize(new Dimension(220, 220)); @Override public void paintcomponent(graphics g) { super.paintcomponent(g); int np = 7; int sc = 100; int i; double theta1, theta2; for(i = 0; i < np; i++) { // theta1 = PI * 2 * i / np; theta2 = PI * 2 * (i + 1) / np; g.drawline((int)(sc * (1.1 + cos(theta1))), (int)(sc * (1.1 + sin(theta1))), (int)(sc * (1.1 + cos(theta2))), (int)(sc * (1.1 + sin(theta2))));... // main // 360 * i / n // 360 * (i + 1) / n Math.PI π =3.1415... Math.sin, Math.cos static import PI, sin, cos 3.3.3 Parabola.java import java.awt.*; import javax.swing.*; public class Parabola extends JPanel { public Parabola() { setpreferredsize(new Dimension(200, 200));; @Override public void paintcomponent(graphics g) { super.paintcomponent(g); double a = -0.0025, b = 1, c = 0; for (int x0 = 0; x0 < 200; x0 += 10) { double y0 = a * x0 * x0 + b * x0 + c; double

Java 3 p.6 3 Java int x1 = x0 + 10; double y1 = a * x1 * x1 + b * x1 + c; g.drawline(x0, (int)y0, x1, (int)y1); System.out.printf("(%d, %.1f) -- (%d, %.1f)", x0, y0, x1, y1);... // main 3.3.4 y = ax 2, y = sin(x), y = cos(x) GUI : (JDKDIR)/docs/ja/api/java.lang.Math.html 3.3.5 n GUI 3.3.6 2 GUI 2 1 1 Gradation1.java import javax.swing.*; import java.awt.*; public class Gradation1 extends JPanel { public Gradation1() { setpreferredsize(new Dimension(256, 64)); @Override public void paintcomponent(graphics g) { super.paintcomponent(g); int scale = 4; int i; for (i = 0; i < 64; i++) {

3.3. for, while, do while Java 3 p.7 g.setcolor(new Color(i * 4, 0, 255 - i * 4)); g.fillrect(i * scale, 0, scale, scale * 10);... // main 3.3.7 Graph.java import java.awt.*; import javax.swing.*; public class Graph extends JPanel { public Graph() { setpreferredsize(new Dimension(200, 150)); @Override public void paintcomponent(graphics g) { super.paintcomponent(g); int[] is = {10, 4, 6, 2, 9, 1; Color[] cs = {Color.RED, Color.BLUE; int scale = 15; int i, n = is.length; for (i = 0; i < n; i++) { g.setcolor(cs[i % cs.length]); g.fillrect(0, i * scale, is[i] * scale, scale);... // main length 3.3.1 (?) C for i 0 n-1 Q 3.3.8 ds double ds 2

Java 3 p.8 3 Java double average(double[] ds) { double n = 0 int i; for (i = 0; i < ; i++) { n += ds[i]; return n / ; C Java ArrayIndexOutOfBoundsException Q 3.3.9 ArrayIndexOutOfBoundsExceptionTest.java public class ArrayIndexOutOfBoundsExceptionTest { public static void main(string args[]) { int[] a = {1, 2, 3; for (int i = 0; i <= a.length; i++) { System.out.println(a[i]); C ArrayIndexOutOfBoundsExceptionTest.c #include <stdio.h> int main(void) { int i, a[] = {1, 2, 3; for (i = 0; i <= sizeof(a) / sizeof(int); i++) { printf("%d\n", a[i]); return 0;

3.4. Java 3 p.9 3.4 3.4.1 int 8 8 1 2 Othello.java import javax.swing.*; import java.awt.*; public class Othello extends JPanel { private final int scale = 40; private final int space = 3; public Othello() { setpreferredsize(new Dimension(scale * 8 + 1, scale * 8 + 1)); @Override public void paintcomponent(graphics g) { super.paintcomponent(g); int[][] state = {{0,1,2,0,1,2,0,1, {2,0,1,2,0,1,2,0, {1,2,0,1,2,0,1,2, {0,1,2,0,1,2,0,1, {2,0,1,2,0,1,2,0, {1,2,0,1,2,0,1,2, {0,1,2,0,1,2,0,1, {2,0,1,2,0,1,2,0; int i, j; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { g.setcolor(color.green); g.fillrect(i * scale, j * scale, scale, scale); g.setcolor(color.black); g.drawrect(i * scale, j * scale, scale, scale); if (state[i][j] == 1) { g.setcolor(color.white); g.filloval(i * scale + space, j * scale + space, scale - space * 2, scale - space * 2); else if (state[i][j] == 2) { g.setcolor(color.black); g.filloval(i * scale + space, j * scale + space, scale - space * 2, scale - space * 2);... // main

Java 3 p.10 3 Java Othello.java 2 [] 2 3 C C state state[0][1] 0 {0,1,2,0,1,2,0,1 1 1 3.4.1 0 1 : Java 2 C 2 Java Java C 2 int[][] xss = {{1, {2, 3, {4, 5, 6; C int xss[][3] = {{1, {2, 3, {4, 5, 6; 1 2 3 4 5 6 1 2 3 4 5 6 C Java Q 3.4.2 int[][] xss = {{1, {2, 3, {4, 5, 6; 1. xss[1][1] : 2. xss[0][1] : 3. xss[2][1] :

3.4. Java 3 p.11 4. xss.length : 5. xss[1].length : if, if else, while, for, for-each,, length, ArrayIndexOutOfBounds, static, Math,,