星期日, 1月 15, 2006

Tower


























星期五, 1月 06, 2006

Lab PGP

Finger print:E01B BD31 FCEF B7D8 2B96 878E F775 938F 9D02 FA2B
public key:
mQENBEO+vokBCAC/b8Mx8kGn7fTFmxpm7pjQQ91GWdl7S3O+r+kTMZYTEwOASQQB
5SPHFELj779FSm0hZ5tMJ1n54MH1RCwOb/u4873YmU0cvnhc7PRzhjcuqMpsyest
S6b28VuE30XUScnV/yf3TKRbszErXWr3ot6eIt0a5ZyI34ytmwPVYER9vrqZAaO3
Zt8cSA9A7Bxktvc293aszuwKR4Q/iTEv5pyQEeE/HzCKenE+FR9SYIUAmIzchbox
DfoostgDLt15wwA497wJ/Hu69TINBpXqg7dKoojscSoqlvsVeBdN1q+FTd0m2u2s
hj0vguwxs38+mxQcgK5ae1IWPPODFW0pns4TABEBAAG0HnNvcGhpYSA8c290cDEy
MTZAeWFob28uY29tLnl3PokBbQQQAQIAVwUCQ76+iTAUgAAAAAAgAAdwcmVmZXJy
ZWQtZW1haWwtZW5jb2RpbmdAcGdwLmNvbXBncG1pbWUHCwkIBwMCCgIZAQUbAwAA
AAMWAgEFHgEAAAAEFQgJCgAKCRD3dZOPnQL6K0cfCACOdCkaH/2i5gMBen/8opS9
9uWpIO05J9drgAwN7YsvqzKu2fGvlZL6biuR/csQIsbarXGaRCqmRQoDVpItxH7d
wFY+L5kjohYpvyASLlrV0+/3hYy0EaP94NYdRksObVqHwYv0Acu2WKil+rMAZDQa
M4lU/L85i+oZS50rNwyueGXqG+NvfHRsYLmLDhF5NnjqrYc2gDVKoC7qpSkah/Kj
aYiHkUG+VQBOMA/YVFfbgQPsxaceGE0dtn8vnFW68TpnipUaLQ31D7fnqV3uwgc5
jou5X1f0tBys7ebhEa4GwJbaP2vgqZEHAQdkVH91zJbx+6PY82mEFthf5AYUAnw7
uQENBEO+vooBCADBgtg2VHluQlQnSamc1ZDwPeTakt2VMMdCSa6YBnqdqS0leVkz
szC7IQRcz4z87aOwhLG6gqEUobwxEXclzUcVjHHBZs5/1pZnPHZnOyUacEGGMhHv
WeNIacTALqG1LwOnbPyUH/DOwf1pUWyJMi8i/9KgIuCoyNXzZgLu5XrBG8KH4k91
j0YHQC16k6wSxc8ivaZDkr+mixBzWRfuT40he/D/fRH2IQ5uEIRmMbs/c1imEucN
vGrvJznKZlhfL70ztEH5RH1PcZOp5OCzcBT3rF+TTSQIe1ES/vIkd9xf9W1b85SX
If7bqfl4sFf1g113aT1QoejXGzryzk7jtV/3ABEBAAGJASIEGAECAAwFAkO+vooF
GwwAAAAACgkQ93WTj50C+iuc8gf+O5dclaWigSzNn0eCfxFZCOg0of6o3ULalfE4
cBNxzh77wXd7sSZZb27k1BZ3d749B31JkRTRD6AlfDRTTDBtXos2uGFaJYQqWD9D
rG4mMzutOLhu6yyOOQ9mxlVDC1jX4Uo4+C+yOJHRsFiIRmEJm21DDnOeBI7kzPr9
lp9UT8awTQ2NZ5dKAPjg3ULXtRs/2eYHR4cL27A3+9eQM3Z7o0TYSvF/GGPt1yA5
9MZKMw79DKPDhlV4Uf7hsUMuR78VdE2mWCXlYXEvRvjhbFJoyOK2Y8LycfG8Nib+
ccyT7+GNSNalwZRPYd8qOt3dGulsjkd5y3iuzffkBIkCYIDXOw==
=oEPw

Length:2048

星期三, 1月 04, 2006

Recursion


















Lab modular sorting




















星期日, 1月 01, 2006

Lab 12-26(2)

















結果:

星期一, 12月 26, 2005

lab 12-26(1)

Homework 12-19





















Sorting

import java.io.*;

public class Sorting {
public static void main(String[] args) throws IOException {
BufferedReader keyboard = new BufferedReader(new InputStreamReader(
System.in));
double[] a = new double[5];
double temp;
int i, j;
System.out.println("Enter 5 number:");
for (i = 0; i <>
a[i] = Double.parseDouble(keyboard.readLine());
}
for (i = 0; i <>
for (j = 0; j <>
if (a[i] <>
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("The answer:");
for (i = 0; i <>
System.out.println(a[i]);
}
}
}

星期四, 12月 22, 2005

complex

package complex1;
public class complextest
{
private double x,y;
public complex(double real, double imaginary)
{
this.x=real;
this.y=imaginary;
}
public double real()
{
return x;
}
public double imaginaty()
{
return y;
}
public void print1()
{
if(y>=0)
System.out.println(x+"+"+y+"i");
else
System.out.println(x+""+y+"i");
}
public static complex add(complex a,complex b)
{
complex test= new complex(0,0);
test.x= a.x + b.x;
test.y= a.y + b.y;
return test;
}
}
-----------------------------------------------------------------------------------
package complex1;
public class complextest2
{
public static void main(String[] args)
{
complex c = new complex(5,6);
complex d = new complex(2,3);
complex.add(c,d).print1();
}
}

測試結果

星期一, 12月 19, 2005

Static class

public class Fibonacci {
public static double num0 = 1, num1 = 1, sum = 0;
public static double next() {
sum = num0 + num1;
num0 = num1;
num1 = sum;
return sum;
}

public static void main(String[] args) {
for (int i = 0; i <>
Fibonacci.next();
System.out.println("F(" + (i + 2) + ") = " + sum);
}
}
}

Homework 12-12

package javacode2;

public class Counter
{
public Counter()
{
count = 0;
}

public void increase()
{
count++;
}

public void decrease()
{
if(count >=1)
count--;
else
count = 0;
}

public int getVasue()
{
return count;
}

public void printcount()
{
System.out.println("counter count is " + count);
}

public boolean equals(Counter otherCounter)
{
return this.count == otherCounter.count;
}

public void resetToZero()
{
count = 0;
}

public String toString()
{
return Integer.toString(count) ;
}

private int count;
}

-----------------------------------------------------------------
package javacode2;

class CounterTest
{
public static void main(String[] args)
{
Counter counter1 = new Counter();
Counter counter2 = new Counter();

counter1.increase();
counter2.increase();

if (counter1.equals(counter2))
{
System.out.println( counter1 + " is equal to " + counter2);
}
else
{
System.out.println( counter1 + " is not equal to " + counter2);
}

counter2.increase();
counter1.decrease();
if (counter1.equals(counter2))
{
System.out.println( counter1 + " is equal to " + counter2);
}
else
{
System.out.println( counter1 + " is not equal to " + counter2);
}
}
}


Homework 12-5-2005

package ccc;
public class temperature
{
private double degree;
private char scale;

public temperature()
{
this.degree=0;
this.scale='c';
}
public temperature(double degree)
{
this.degree=degree;
this.scale='c';
}
public temperature(char scale)
{
this.degree=0;
if(scale=='f'||scale=='F')
{
this.scale='F';
}
else if(scale=='c'||scale=='C')
{
this.scale='C';
}
else
{
System.out.println("error scale and please scale set C");
this.scale='C';
}
}
public temperature(double degree,char scale)
{
this.degree=degree;
if(scale=='f'||scale=='F')
{
this.scale='F';
}
else if(scale=='c'||scale=='C')
{
this.scale='C';
}
else
{
System.out.println("error scale and please scale set C");
this.scale='C';
}
}
public double get_temperatureC()
{
double degreesC=0;
if(scale=='C')
{
degreesC=degree;
}
else if(scale=='F')
{
degreesC = (degree -32 )*5/9;
}
return degreesC;
}
public double get_temperatureF()
{
double degreesF=0;
if(scale=='F')
{
degreesF=degree;
}
else if(scale=='C')
{
degreesF = (degree *9/5 )+32;
}
return degreesF;
}
public void setdegree(double degree)
{
this.degree=degree;
}
public void setScale(char scale)
{
if(scale=='f'||scale=='f')
{
this.scale='F';
}
else if(scale=='c'||scale=='C')
{
this.scale='C';
}
else
{
System.out.println("Error scale and scale no change");
}
}
public void setScale(double degree,char scale)
{
if(scale=='f'||scale=='f')
{
this.scale='F';
}
else if(scale=='c'||scale=='C')
{
this.scale='C';
}
else
{
System.out.println("Error scale and scale no change");
}
this.degree=degree;
}
public boolean isequals(temperature othertemp)
{
if (this.scale == 'C' && this.degree == othertemp.get_temperatureC())
{
return true;
}
else if (this.scale == 'F' && this.degree == othertemp.get_temperatureF())
{
return true;
}
else
{
return false;
}
}
public boolean isgreaterthan(temperature otherTemp)
{
if (this.scale == 'C' && this.degree >= otherTemp.get_temperatureC())
{
return true;
}
else if (this.scale == 'F' && this.degree >= otherTemp.get_temperatureF())
{
return true;
}
else
{
return false;
}
}
public boolean islessthan(temperature otherTemp)
{
if (this.scale == 'C' && this.degree <= otherTemp.get_temperatureC())
{
return true;
}
else if (this.scale == 'F' && this.degree <= otherTemp.get_temperatureF())
{
return true;
}
else
{
return false;
}
}

public String toString()
{
return Double.toString(degree) + scale;
}
}


----------------------------------------------------------------------------------------------

package ccc;
public class temperature_a
{
public static void main(String[] args)
{

temperature cloudC = new temperature(0.0, 'C');
temperature cloudF = new temperature(32.0, 'F');
temperature hotC = new temperature(100.0);
hotC.setScale('C');
temperature hotF = new temperature(212.0);
hotF.setScale('F');

temperature degreeC = new temperature();
degreeC.setScale(-40.0, 'C');
temperature degreeF = new temperature();
degreeF.setScale('F');
degreeF.setdegree( -40.0);

System.out.println("cloudC = " + cloudC );
System.out.println("cloudF = " + cloudF );
System.out.println("hotC = " + hotC );
System.out.println("hotF = " + hotF );
System.out.println("degreeC = " + degreeC + " , " + degreeC.get_temperatureF() + "F");
System.out.println("degreeF = " + degreeF + " , " + degreeF.get_temperatureC() + "C");

System.out.print("Test isequals");
System.out.println(cloudC + " = " + degreeC + " ? " + cloudC.isequals(degreeC));
System.out.println(cloudC + " = " + cloudF + " ? " + cloudC.isequals(cloudF));
System.out.println(cloudF + " = " + degreeC + " ? " + cloudF.isequals(degreeC));
System.out.println(cloudF + " = " + cloudC + " ? " + cloudF.isequals(cloudC));

System.out.print("Test islessthan");
System.out.println(cloudC + " <= " + degreeC + " ? " + cloudC.islessthan(degreeC));
System.out.println(cloudC + " <= " + hotF + " ? " + cloudC.islessthan(hotF));
System.out.println(cloudF + " <= " + degreeC + " ? " + cloudF.islessthan(degreeC));
System.out.println(cloudF + " <= " + hotC + " ? " + cloudF.islessthan(hotC));

System.out.print("Test isgreaterthan");
System.out.println(cloudC + " >= " + hotC + " ? " +cloudC.isgreaterthan(hotC));
System.out.println(cloudC + " >= " + degreeF + " ? " + cloudC.isgreaterthan(degreeF));
System.out.println(cloudF + " >= " + hotF + " ? " + cloudF.isgreaterthan(hotF));
System.out.println(cloudF + " >= " + degreeF + " ? " + cloudF.isgreaterthan(degreeF));
}
}