Java http://cafedaumnet/pway
Chapter 1 1 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); 11 public static void main(string args[]){ Systemoutprintln("This is my first Program"); public static void main(string args[]){ Systemoutprintln("------------------------"); Systemoutprintln("This is my first Program"); Systemoutprintln("------------------------"); public static void main(string args[]){ Systemoutprint("------------------------\n"); Systemoutprint("This is my first Program\n"); Systemoutprint("------------------------\n"); 12
public static void main(string args[]){ int a, b, c; a = 1; b = 2; c = a + b; Systemoutprintln("a = "+ a + ", b = " + b + ", c = " + c); 13 public static void main(string args[])throws Exception{ int a, b, c; Systemoutprint("please enter first number(a): "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); a = IntegerparseInt(inputNumreadLine()); Systemoutprint("please enter second number(b): "); inputnum = new BufferedReader(new InputStreamReader(Systemin)); b = IntegerparseInt(inputNumreadLine()); c = a + b; Systemoutprintln("a = "+ a + ", b = " + b + ", c = " + c); 14 public static void main(string args[])throws Exception{ int n;
Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++) { Systemoutprint("yes "); Systemoutprintln("i=" + i + ": print " + n +" many yes "); public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++) { Systemoutprintln("i=" + i + ": print the numbers from 0 to " + (n-1)); 141 for 1 for(int i=0;i<10;i++) Systemoutprintln("yes "); for(int i=0;i<100;i++) Systemoutprintln("happy "); for(int i=0;i<1000;i++) Systemoutprintln("laugh "); 142 for 2 for(int i=0;i<n;i++) Systemoutprintln("yes ");
143 for 3 for(int i=0;i<n;i++) Systemoutprintln("yes "); for( ; ; ) 144 for 4 for(int i=0;i<n;i++) Systemoutprintln( i );
Chapter 2 2 21 public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ Systemoutprint( (i+1) ); public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ Systemoutprint(format4(i+1)); public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring();
public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(j+1)); 211 for 5 1: 2: 3: 4: 5: public static String format4(int targetnum){ 6: String strnum = new String(IntegertoString(targetNum)); 7: StringBuffer resultstr = new StringBuffer(); 8: for(int i = strnumlength(); i < 4 ; i++){ 9: resultstrappend(' '); 10: 11: return (resultstrappend(strnum))tostring(); 12: 13: public static void main(string args[])throws Exception{ 14: int n; 15: Systemoutprint("please enter number : "); 16: BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); 17: n = IntegerparseInt(inputNumreadLine()); 18: 19: 20: for(int i =0; i<n; i++){ 21: for(int j =0; j<n; j++){ 22: Systemoutprint(format4(j+1)); 23: 24: 25: 26: 27: 212 for 6
1: 2: 3: 4: 5: public static String format4(int targetnum){ 6: String strnum = new String(IntegertoString(targetNum)); 7: StringBuffer resultstr = new StringBuffer(); 8: for(int i = strnumlength(); i < 4 ; i++){ 9: resultstrappend(' '); 10: 11: return (resultstrappend(strnum))tostring(); 12: 13: public static void main(string args[])throws Exception{ 14: int n; 15: Systemoutprint("please enter number : "); 16: BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); 17: n = IntegerparseInt(inputNumreadLine()); 18: 19: 20: for(int i =0; i<n; i++){ 21: for(int j =0; j<n; j++){ 22: Systemoutprint(format4(j+1)); 23: 24: 25: 26: 27: 20 for : i=0 i 0 : i<3 : 21-25 21 for : j=0 j 0 : j<3 : Systemoutprint( format4(j+1) ); 1 : j++ j 1 : j<3 : Systemoutprint( format4(j+1) ); 2 : j++ j 2 : j<3 : Systemoutprint( format4(j+1) ); 3 : j++ j 3 j<3 for (21 ) 24 (21-25 ) : i++ i 1 : i<3 : 21-25 21 for : j=0 j 0 : j<3 : Systemoutprint( format4(j+1) ); 1 : j++ j 1 : j<3 : Systemoutprint( format4(j+1) ); 2 : j++ j 2 : j<3 : Systemoutprint( format4(j+1) ); 3 : j++ j 3 j<3
for (21 ) 24 (21-25 ) : i++ i 2 : i<3 : 21-25 21 for : j=0 j 0 : j<3 : Systemoutprint( format4(j+1) ); 1 : j++ j 1 : j<3 : Systemoutprint( format4(j+1) ); 2 : j++ j 2 : j<3 : Systemoutprint( format4(j+1) ); 3 : j++ j 3 j<3 for (21 ) 24 (21-25 ) : i++ i 3 : i<3 for (20 ) 22 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(j+1));
23 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int n, k; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); k = 1; for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint( format4(k++) ); 24 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){
for(int j =0; j<i+1; j++){ Systemoutprint( format4(j+1) ); public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ for(int j =0; j<n-i; j++){ Systemoutprint(format4(j+1)); 241 for 7 1: 2: 3: 4: 5: public static String format4(int targetnum){ 6: String strnum = new String(IntegertoString(targetNum)); 7: StringBuffer resultstr = new StringBuffer(); 8: for(int i = strnumlength(); i < 4 ; i++){ 9: resultstrappend(' '); 10: 11: return (resultstrappend(strnum))tostring(); 12: 13: 14: public static void main(string args[])throws Exception{ 15: int n, k; 16: Systemoutprint("please enter number : "); 17: BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); 18: n = IntegerparseInt(inputNumreadLine()); 19: 20: 21: k = 1; 22: for(int i =0; i<n; i++){ 23: for(int j =0; j<n; j++){ 24: Systemoutprint(format4(k++)); 25: 26: 27: 28: 29:
21 k=1; k 1 22 for : i=0 i 0 : i<3 : 23-27 23 for : j=0 j 0 : j<3 : Systemoutprint(format4(k++)); 1 k 2 : j++ j 1 : j<3 : Systemoutprint(format4(k++)); 2 k 3 : j++ j 2 : j<3 : Systemoutprint(format4(k++)); 3 k 4 : j++ j 3 j<3 for (23 ) 26 (23-27 ) : i++ i 1 : i<3 : 23-27 23 for : j=0 j 0 : j<3 : Systemoutprint(format4(k++)); 4 k 5 : j++ j 1 : j<3 : Systemoutprint(format4(k++)); 5 k 6 : j++ j 2 : j<3 : Systemoutprint(format4(k++)); 6 k 7 : j++ j 3 j<3 for (23 ) 26 (23-27 ) : i++ i 2 : i<3 : 23-27 23 for : j=0 j 0 : j<3 : Systemoutprint(format4(k++)); 7 k 8 : j++ j 1 : j<3 : Systemoutprint(format4(k++)); 8 k 9 : j++ j 2 : j<3 : Systemoutprint(format4(k++)); 9 k 10 : j++ j 3 j<3 for (23 ) 26
(23-27 ) : i++ i 3 : i<3 for (22 ) 242 for 8 1: 2: 3: 4: 5: public static String format4(int targetnum){ 6: String strnum = new String(IntegertoString(targetNum)); 7: StringBuffer resultstr = new StringBuffer(); 8: for(int i = strnumlength(); i < 4 ; i++){ 9: resultstrappend(' '); 10: 11: return (resultstrappend(strnum))tostring(); 12: 13: 14: public static void main(string args[])throws Exception{ 15: int n; 16: Systemoutprint("please enter number : "); 17: BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); 18: n = IntegerparseInt(inputNumreadLine()); 19: 20: 21: for(int i =0; i<n; i++){ 22: for(int j =0; j<i+1; j++){ 23: Systemoutprint(format4(j+1) ); 24: 25: 26: 27: 28: 243 for 9 1: 2: 3: 4:
5: public static String format4(int targetnum){ 6: String strnum = new String(IntegertoString(targetNum)); 7: StringBuffer resultstr = new StringBuffer(); 8: for(int i = strnumlength(); i < 4 ; i++){ 9: resultstrappend(' '); 10: 11: return (resultstrappend(strnum))tostring(); 12: 13: 14: public static void main(string args[])throws Exception{ 15: int n; 16: Systemoutprint("please enter number : "); 17: BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); 18: n = IntegerparseInt(inputNumreadLine()); 19: 20: 21: for(int i =0; i<n; i++){ 22: for(int j =0; j<n-i; j++){ 23: Systemoutprint(format4(j+1)); 24: 25: 26: 27: 28:
Chapter 3 -
Chapter 4 if 1) 1-1) number = 5 1-2) number = 5 1-3) number = 5 1-4) number = 5 1-5) number = 5 1-6) number = 5
1-7) number = 5 1-8) number = 5 1-9) number = 5 1-10) number = 5
Chapter 5 for Systemoutprint 2) 2-1) number = 5 2-2) number = 5 2-3) number = 5 2-4) number = 5 2-5) number = 5
2-6) number = 5 2-7) number = 5 [ n, 2-8 ] 2-8) number = 5 [ 2*n ] 2-9) number = 5
2-10) number = 5 [ n+2 + n+1 = 2*n + 3 ] [ *2 ] [ *1 ]
Chapter 6 61 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n, k; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); k=0; for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ a[i][j] = k++; for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j]));
611 1 1) int a[][] = new int[30][30]; 2) int a[] = {1, 2, 3, 4, 5, 6; 3) int a[][] = {{1, 2, 3, 4, 5, 6,{ 7, 8, 9, 10, 11, 12;
612 2 1: 2: 3: 4: public static String format4(int targetnum){ 5: String strnum = new String(IntegertoString(targetNum)); 6: StringBuffer resultstr = new StringBuffer(); 7: for(int i = strnumlength(); i < 4 ; i++){ 8: resultstrappend(' '); 9: 10: return (resultstrappend(strnum))tostring(); 11: 12: 13: public static void main(string args[])throws Exception{ 14: int[][] a = new int[30][30]; 15: int n, k; 16: Systemoutprint("please enter number : "); 17: BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); 18: n = IntegerparseInt(inputNumreadLine()); 19: 20: k=0; 21: 22: for(int i =0; i<n; i++){ 23: for(int j =0; j<n; j++){ 24: a[i][j] = k++; 25: 26: 27: for(int i =0; i<n; i++){ 28: for(int j =0; j<n; j++){ 29: Systemoutprint(format4(a[i][j])); 30: 31: 32: 33: 34: 62 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){
for(int j =0; j<n; j++){ a[i][j] = j+1; //[A] for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j])); : a[i][j] = i+1; : a[i][j] = i+j+1; : a[i][j] = i-j; : a[i][j] = j-i; : a[i][j] = (i+1)*(j+1); 63 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ a[i][i] = i+1; //[A] for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j])); : a[i][i]=n-i; : a[0][i]=i+1; : a[n-1][i]=i+1; : a[i][0]=i+i; : a[i][n-1]=i+1; : a[i][n-i-1]=i+1;
64 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n, k; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); k=0; for(int i =0; i<n; i++){ a[i][i] = k++; //[A] for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j])); : a[0][i]=k++; : a[n-1][i]=k++; : a[i][0]=k++; : a[i][n-1]=k++; : a[i][n-i-1]=k++; : a[n-i-1][i]=k++; 65 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n, k; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine());
k=0; for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ a[i][j] = k++; //[A] for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j])); : a[j][i]=k++; : a[i][n-j-1]=k++; : a[n-i-][j]=k++; : a[n-i-1][n-j-1]=k++; : a[j][n-i-1]=k++; : a[n-j-1][i]=k++; 66 public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i=0; i<n; i++){ if((i%2)==0){ Systemoutprintln("i = "+ i+" is even number");// else{ Systemoutprintln("i = "+ i+" is odd number");// 67 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring();
public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ if(i==j){ a[i][j] = 9; else{ a[i][j] = 1; for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j])); public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[][] a = new int[30][30]; int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ if(i>j){ a[i][j] = 9; else{ a[i][j] = 1; for(int i =0; i<n; i++){ for(int j =0; j<n; j++){ Systemoutprint(format4(a[i][j]));
Chapter 7 (2 ) 3) 2 3-1) 1 3-2) 1 3-3) 1 3-4) 1 i
3-5) 9 0 number = 7 9 9 9 9 9 9 9 9 9 0 0 0 9 9 9 0 9 0 9 0 9 9 0 0 9 0 0 9 9 0 9 0 9 0 9 9 9 0 0 0 9 9 9 9 9 9 9 9 9 3-6) (i j) 0 1 (+,-,*,/) number = 5 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 3-7) 3-6 number = 6 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1 1 3-8) 3-6 number = 6 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 3-6, 3-7, 3-8) 3-9) 1 number = 5 1 2 3 4 5 16 0 0 0 6 15 0 0 0 7 14 0 0 0 8 13 12 11 10 9
3-10) 1 number = 5 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 3-11) number number = 5 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 3 3 3-12) 1 number = 5 1 3 6 10 15 2 5 9 14 19 4 8 13 18 22 7 12 17 21 24 11 16 20 23 25 3-13) number = 3 : 8 1 6 3 5 7 4 9 2 number = 5 : 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 1 (3X3, 5x5) 2 3 4 5 3x3 1 a[0][1] 2 a[-1][2] -1 a[2][2] 3
a[1][3] 3 a[1][0] 4 a[0][1] a[2][0] 5 a[1][1] 6 a[0][2] 7 a[-1][3] -1, 3 a[2][0] a[0][2] a[1][2] 8 a[0][3] 3 a[0][0] 9 a[-1][1] a[2][1]
Chapter 8 - public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int n; Systemoutprint("please enter number : "); BufferedReader inputnum = new BufferedReader(new InputStreamReader(Systemin)); n = IntegerparseInt(inputNumreadLine()); int i=0; while(i<n){ Systemoutprintln(" i =" + format4(i) ); i++; for(int i=0;i<n;i++) Systemoutprintln(" i =" + format4(i) ); while( ) { ; public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[] a = new int[100]; Systemoutprintln("Print the contents of array a[]"); a[0] = 1; a[1] = 2; a[2] = 3; a[3] = 4; a[4] = 5;
a[5] = 6; a[6] = 7; a[7] = 8; a[8] = 9; a[9] = 10; int i=0; while(a[i]>0){ Systemoutprint(" i =" + format4(a[i]) ); i++; public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[] a = new int[100]; Systemoutprintln("Print the contents of array a[]"); a[0] = 11; a[1] = 12; a[2] = 13; a[3] = 14; a[4] = 15; a[5] = 6; a[6] = 7; a[7] = 8; a[8] = 9; a[9] = 10; int i=0; while(a[i]>0){ if(a[i]>10){ Systemoutprint(" big"); else{ Systemoutprint(" small"); i++; public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum));
StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[] a = new int[100]; Systemoutprintln("Print the contents of array a[]"); a[0] = 11; a[1] = 12; a[2] = 13; a[3] = 14; a[4] = 15; a[5] = 6; a[6] = 7; a[7] = 8; a[8] = 9; a[9] = 10; int i=0; while(true){ if(a[i]<=0){ break; if(a[i]>10){ Systemoutprint(" big"); else{ Systemoutprint(" small"); i++; public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength(); i < 4 ; i++){ resultstrappend(' '); return (resultstrappend(strnum))tostring(); public static void main(string args[])throws Exception{ int[] a = new int[100]; int[] b = new int[100]; Systemoutprintln("Print the contents of array a[]"); a[0] = 11; a[1] = 12; a[2] = 13; a[3] = 14; a[4] = 15; a[5] = 6; a[6] = 7; a[7] = 8; a[8] = 9;
a[9] = 10; int i=0; while(a[i]>0){// a[] b[] b[i]=a[i]; i++; Systemoutprintln("Print the array b[]"); i=0; while(b[i]>0){ Systemoutprint(format4(b[i])); i++;
Chapter 9 91 92 for(i=0;i<1000;i++) a[i]=i; 2 4 2 2 a[] 0 4, 6, 8, 10, 12, 14,,,, 2 3 3 6 3 3 6, 9, 12, 15, 18, 21,,,, 3 5 5 10 5 5 10, 15, 20, 25, 30, 35,,,, 5 7 7 14 7 7 14, 21, 28, 35, 42, 27,,,, 7 11 11
93 a[0]=2; a[1]=3; 5 5 3 3 9 9 5 5 a[2]=5; 7 3 3 9 9 7 7 a[3]=7 9 3 3 9 9 9 9 11 3 3 9 9 11 11 3 11 5 5 25 25 11 11 a[4]=11 13 3 3 9 9 13 13 3 13 5 5 25 25 13 13 a[5]=13 15 3 3 9 9 15 15 3 17 3 3 9 9 17 17 3 17 5 5 25 25 17 17 a[6]=17 19 3
Chapter 10 public class FileEx1 { public static void main(string[] args) throws Exception { Systemoutprintln("\nPlease enter File name:"); BufferedReader inputname; inputname = new BufferedReader(new InputStreamReader(Systemin)); String filename = inputnamereadline(); int c; RandomAccessFile raf = new RandomAccessFile(filename, "r"); c = rafread(); while(c!= -1) { Systemoutprint((char)c); c = rafread(); rafclose(); c = rafread(); c = rafread(); while(c!= -1) { Systemoutprint((char)c); c = rafread();
101 public class FileEx2 { public static void main(string[] args) { char a, b, c; a = 'A'; b = 'B'; c = 'C'; Systemoutprintln(a + " " + b + " " + c); A B C Systemoutprintln((int)a + " " + (int)b + " " + (int)c); 65 66 67 public class FileEx3 { public static void main(string[] args) { int a, b, c; a = 65; b = 66; c = 67; Systemoutprintln((char)a + " " + (char)b + " " + (char)c); A B C public class FileEx4 { public static void main(string[] args) throws Exception { String filename; String foutname; int c;
BufferedReader inputname; inputname = new BufferedReader(new InputStreamReader(Systemin)); Systemoutprintln("\nPlease enter input file name:"); filename = inputnamereadline(); Systemoutprintln("\nPlease enter output file name:"); foutname = inputnamereadline(); RandomAccessFile fin = new RandomAccessFile(filename, "r"); RandomAccessFile fout = new RandomAccessFile(foutname, "rw"); c = finread(); while(c!= -1) { foutwrite(c); c = finread(); finclose(); foutclose(); 102 public class FileEx4 { public static void main(string[] args) throws Exception { public class FileEx5 { public static void main(string[] args) throws Exception { String fname; int c; Systemoutprintln("\nPlease enter input file name:");
BufferedReader inputname; inputname = new BufferedReader(new InputStreamReader(Systemin)); fname = inputnamereadline(); RandomAccessFile fin = new RandomAccessFile(fname, "r"); c = finread(); while(c!= -1) { Systemoutprint(IntegertoHexString(c) + " "); c = finread(); finclose();
Chapter 11 4-1) ( ) ;*oiavaj tropmi { 1xE ssalc cilbup { )sgra ][gnirts(niam diov citats cilbup ;n,j,i tni 4-2) ( ) int i, j, n; public static void main(string[] args) { public class Ex2 { 4-3) ( ) i p m u p b o l r i p t c u b j c l a l i v a c i a s n s s t i t o E a i x t, * 3 i ; c j {, v o n i ; d 4-4) $$$ ( ) $$$ public class Ex4 {$$$public class Ex4-2 { public static void main(string[] args) {$$$public static void main(string[] args) { int i, j, n;$$$int a10={0,; 4-5) 4-4
$$$;*oiavaj tropmi public class Ex5 {$$${ 5xE ssalc cilbup public static void main(string[] args) {$$${ )sgra ][gnirts(niam diov citats cilbup int i, j, n;$$$;n,j,i tni 4-6) hexa ( 16 ) 1 6 2 16 3 4 8 5 3 6 <!-- ( isprint )--> 7 000000 69 6d 70 6f 72 74 20 6a 61 76 61 2e 69 6f 2e 2a import javaio* 000010 3b 0d 0a 0d 0a 70 75 62 6c 69 63 20 63 6c 61 73 ;public clas 000020 73 20 73 6f 6c 34 35 20 7b 0d 0a 20 20 20 20 70 s sol45 { p 000030 75 62 6c 69 63 20 73 74 61 74 69 63 20 76 6f 69 ublic static voi 000040 64 20 6d 61 69 6e 28 53 74 72 69 6e 67 5b 5d 20 d main(string[] 000050 61 72 67 73 29 20 74 68 72 6f 77 73 20 49 4f 45 args) throws IOE 000060 78 63 65 70 74 69 6f 6e 20 7b 0d 0a 0d 0a 20 20 xception { 000070 20 20 20 20 20 20 69 6e 74 20 69 3b 0d 0a 20 20 int i; 000080 20 20 20 20 20 20 53 74 72 69 6e 67 20 73 74 20 String st 000090 3d 20 22 20 22 2c 20 73 74 72 20 3d 20 22 20 22 = " ", str = " " 0000a0 2c 20 74 65 6d 70 20 3d 20 22 20 22 3b 0d 0a 3d, temp = " "; 0000b0 3a 20 20 20 20 20 20 20 20 74 72 79 20 7b 0d 0a try { 0000c0 20 20 20 20 20 20 20 20 20 20 20 20 52 61 6e 64 Rand 0000d0 6f 6d 41 63 63 65 73 73 46 69 6c 65 20 69 6e 20 omaccessfile in 0000e0 3d 20 6e 65 77 20 52 61 6e 64 6f 6d 41 63 63 65 = new RandomAcce 000550 0d 0a 20 20 20 20 7d 0d 0a 7d public class Ex6 { public static void main(string[] args) throws Exception { String fname; int line[] = new int[100]; int c; Systemoutprintln("\nPlease enter input file name:"); BufferedReader inputname; inputname = new BufferedReader(new InputStreamReader(Systemin)); fname = inputnamereadline(); RandomAccessFile fin = new RandomAccessFile(fname, "r"); c = finread(); while(c!= -1) { if(c!= 13) { else { 13 0D 0D 0A
c = finread(); while finclose(); c = finread(); while(c!= -1) { c = finread(); if(c!= 13) { else { 13 ( 0D) 0A public class Ex6_2 { public static void main(string[] args) throws Exception { String fname1, fname2; int line[] = new int[100]; int c, d; Systemoutprintln("\nPlease enter input file name:"); BufferedReader inputname; inputname = new BufferedReader(new InputStreamReader(Systemin)); fname1 = inputnamereadline(); Systemoutprintln("\nPlease enter input file name:"); fname2 = inputnamereadline(); RandomAccessFile fin1 = new RandomAccessFile(fname1, "r"); RandomAccessFile fin2 = new RandomAccessFile(fname2, "r"); c=0; d=0; while(c!= -1 && d!= -1) { c = fin1read(); while((c!= -1)&&(c!= 13)) { c = fin1read(); // while loop -1 13
if(c!= -1) { 13 0D 0D 0A else { // d = fin2read(); while((d!= -1)&&(d!= 13)) { d = fin2read(); // while loop -1 13 if(c!= -1) { 13 0D 0D 0A else { // file1 file2 fin1close(); fin2close();