mport java.io.*;
import java.util.*;
public class Test1
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO 自動產生方法 Stub
Myprint1 myprint = new Myprint1();
myprint.mytest();
}
}
class Myprint
{
Myprint()
{
}
void mytest()
{
String inputs = "";
try
{
FileReader myinpufile = new FileReader("940305.SM");
BufferedReader isr = new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile = new FileWriter("940305w.SM");
BufferedWriter isrw = new BufferedWriter(myoutfile);
int[][] a = new int[2][2];
int[][] b = new int[2][2];
int[][] c = new int[2][2];
for (int i = 1; i <= 1; i++)
{
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken = new StringTokenizer(inputs, ",");
a[0][0] = Integer.parseInt(mytoken.nextToken());
a[0][1] = Integer.parseInt(mytoken.nextToken());
//System.out.println(a[0][0]);
//System.out.println(a[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken2 = new StringTokenizer(inputs, ",");
a[1][0] = Integer.parseInt(mytoken2.nextToken());
a[1][1] = Integer.parseInt(mytoken2.nextToken());
//System.out.println(a[1][0]);
//System.out.println(a[1][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken3 = new StringTokenizer(inputs, ",");
b[0][0] = Integer.parseInt(mytoken3.nextToken());
b[0][1] = Integer.parseInt(mytoken3.nextToken());
//System.out.println(b[0][0]);
//System.out.println(b[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken4 = new StringTokenizer(inputs, ",");
b[1][0] = Integer.parseInt(mytoken4.nextToken());
b[1][1] = Integer.parseInt(mytoken4.nextToken());
//System.out.println(b[1][0]);
//System.out.println(b[1][1]);
c[0][0] = a[0][0] + b[0][0];
c[1][0] = a[1][0] + b[1][0];
c[0][1] = a[0][1] + b[0][1];
c[1][1] = a[1][1] + b[1][1];
System.out.println("\n[" + c[0][0] + " " + c[0][1] + "]");
System.out.println("\n[" + c[1][0] + " " + c[1][1] + "]");
isrw.write("\n[" + c[0][0] + " " + c[0][1] + "]");
isrw.write("\n[" + c[1][0] + " " + c[1][1] + "]");
}
isrw.flush();
myoutfile.close();
}
catch (Exception e)
{ }
System.out.println("Hello");
}
}
class Myprint1 extends Myprint
{
}
2010年6月11日 星期五
import java.io.*;
import java.util.*;
public class Test
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO 自動產生方法 Stub
Myprint1 myprint = new Myprint1();
mprint.mytest();
}
}
class Myprint
{
Myprint()
{
}
void mytest()
{
String inputs = "";
try
{
FileReader myinpufile = new FileReader("940305.SM");
BufferedReader isr = new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile = new FileWriter("940305w.SM");
BufferedWriter isrw = new BufferedWriter(myoutfile);
int[][] a = new int[2][2];
int[][] b = new int[2][2];
int[][] c = new int[2][2];
for (int i = 1; i <= 1; i++)
{
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken = new StringTokenizer(inputs, ",");
a[0][0] = Integer.parseInt(mytoken.nextToken());
a[0][1] = Integer.parseInt(mytoken.nextToken());
//System.out.println(a[0][0]);
//System.out.println(a[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken2 = new StringTokenizer(inputs, ",");
a[1][0] = Integer.parseInt(mytoken2.nextToken());
a[1][1] = Integer.parseInt(mytoken2.nextToken());
//System.out.println(a[1][0]);
//System.out.println(a[1][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken3 = new StringTokenizer(inputs, ",");
b[0][0] = Integer.parseInt(mytoken3.nextToken());
b[0][1] = Integer.parseInt(mytoken3.nextToken());
//System.out.println(b[0][0]);
//System.out.println(b[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken4 = new StringTokenizer(inputs, ",");
b[1][0] = Integer.parseInt(mytoken4.nextToken());
b[1][1] = Integer.parseInt(mytoken4.nextToken());
//System.out.println(b[1][0]);
//System.out.println(b[1][1]);
c[0][0] = a[0][0] + b[0][0];
c[1][0] = a[1][0] + b[1][0];
c[0][1] = a[0][1] + b[0][1];
c[1][1] = a[1][1] + b[1][1];
System.out.println("\n[" + c[0][0] + " " + c[0][1] + "]");
System.out.println("\n[" + c[1][0] + " " + c[1][1] + "]");
isrw.write("\n[" + c[0][0] + " " + c[0][1] + "]");
isrw.write("\n[" + c[1][0] + " " + c[1][1] + "]");
}
isrw.flush();
myoutfile.close();
}
catch (Exception e)
{ }
System.out.println("Hello");
}
}
class Myprint1 extends Myprint
{
}
import java.util.*;
public class Test
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO 自動產生方法 Stub
Myprint1 myprint = new Myprint1();
mprint.mytest();
}
}
class Myprint
{
Myprint()
{
}
void mytest()
{
String inputs = "";
try
{
FileReader myinpufile = new FileReader("940305.SM");
BufferedReader isr = new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile = new FileWriter("940305w.SM");
BufferedWriter isrw = new BufferedWriter(myoutfile);
int[][] a = new int[2][2];
int[][] b = new int[2][2];
int[][] c = new int[2][2];
for (int i = 1; i <= 1; i++)
{
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken = new StringTokenizer(inputs, ",");
a[0][0] = Integer.parseInt(mytoken.nextToken());
a[0][1] = Integer.parseInt(mytoken.nextToken());
//System.out.println(a[0][0]);
//System.out.println(a[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken2 = new StringTokenizer(inputs, ",");
a[1][0] = Integer.parseInt(mytoken2.nextToken());
a[1][1] = Integer.parseInt(mytoken2.nextToken());
//System.out.println(a[1][0]);
//System.out.println(a[1][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken3 = new StringTokenizer(inputs, ",");
b[0][0] = Integer.parseInt(mytoken3.nextToken());
b[0][1] = Integer.parseInt(mytoken3.nextToken());
//System.out.println(b[0][0]);
//System.out.println(b[0][1]);
inputs = isr.readLine();
System.out.println(inputs);
StringTokenizer mytoken4 = new StringTokenizer(inputs, ",");
b[1][0] = Integer.parseInt(mytoken4.nextToken());
b[1][1] = Integer.parseInt(mytoken4.nextToken());
//System.out.println(b[1][0]);
//System.out.println(b[1][1]);
c[0][0] = a[0][0] + b[0][0];
c[1][0] = a[1][0] + b[1][0];
c[0][1] = a[0][1] + b[0][1];
c[1][1] = a[1][1] + b[1][1];
System.out.println("\n[" + c[0][0] + " " + c[0][1] + "]");
System.out.println("\n[" + c[1][0] + " " + c[1][1] + "]");
isrw.write("\n[" + c[0][0] + " " + c[0][1] + "]");
isrw.write("\n[" + c[1][0] + " " + c[1][1] + "]");
}
isrw.flush();
myoutfile.close();
}
catch (Exception e)
{ }
System.out.println("Hello");
}
}
class Myprint1 extends Myprint
{
}
2010年6月10日 星期四
BMI值
import java.io.*;
import java.util.*;
import java.lang.Math;
public class Myjava0528 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動產生方法 Stub
String inputs="";
double a,b,c,d,BMI;
try{
FileReader myinpufile=new FileReader("940304.SM");
BufferedReader isr=new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile=new FileWriter("940304w.SM");
BufferedWriter isrw=new BufferedWriter(myoutfile);
for (int i=1;i<=3;i++)
{
inputs=isr.readLine();
isrw.write(inputs);
StringTokenizer mytoken=new StringTokenizer(inputs,",");
a = Double.parseDouble( mytoken.nextToken());
System.out.println(a);
b = Double.parseDouble( mytoken.nextToken());
System.out.println(b);
c = a / 100;
d= b / (c*c);
BMI=Math.round(d);
System.out.println(BMI);
if(BMI>=24)isrw.write("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",過輕!");
if(BMI>=24)System.out.printf("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",過輕!");
System.out.println("\n");
}
isrw.flush();
myoutfile.close(); }
catch(Exception e)
{ }
}
}
import java.util.*;
import java.lang.Math;
public class Myjava0528 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動產生方法 Stub
String inputs="";
double a,b,c,d,BMI;
try{
FileReader myinpufile=new FileReader("940304.SM");
BufferedReader isr=new BufferedReader(myinpufile);
//System.out.println(isr.readLine());
FileWriter myoutfile=new FileWriter("940304w.SM");
BufferedWriter isrw=new BufferedWriter(myoutfile);
for (int i=1;i<=3;i++)
{
inputs=isr.readLine();
isrw.write(inputs);
StringTokenizer mytoken=new StringTokenizer(inputs,",");
a = Double.parseDouble( mytoken.nextToken());
System.out.println(a);
b = Double.parseDouble( mytoken.nextToken());
System.out.println(b);
c = a / 100;
d= b / (c*c);
BMI=Math.round(d);
System.out.println(BMI);
if(BMI>=24)isrw.write("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)isrw.write("\n您的 BMI 指數是 "+BMI+",過輕!");
if(BMI>=24)System.out.printf("\n您的 BMI 指數是 "+BMI+",過重! ");
else if(BMI>=18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",標準!");
else if(BMI<18.5)System.out.printf("\n您的 BMI 指數是 "+BMI+",過輕!");
System.out.println("\n");
}
isrw.flush();
myoutfile.close(); }
catch(Exception e)
{ }
}
}
迴文判斷
mport java.io.*;
import java.util.*;
public class Around0521 {
public static void main(String args[]) throws IOException{
FileReader inputjerry=new FileReader("940301.SM");
BufferedReader binputjerry=new BufferedReader(inputjerry);
// System.out.print("(迴文判斷)請輸入字母或數字:");
String s1=binputjerry.readLine();
String s2="";
for (int i=s1.length();i>0;i--){
char ch =s1.charAt(i-1);
s2=s2+ch;
}
if (s1.equals(s2)) System.out.println(s1+" is a palindrome"); //如果s1=s2
else System.out.println(s1+" is not a palindrome");
FileWriter outputjerry=new FileWriter("940301.T01");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
if (s1.equals(s2)) boutputjerry.write(String.valueOf(s1+" is a palindrome"));
else boutputjerry.write(String.valueOf(s1+" is not a palindrome"));
boutputjerry.flush();
boutputjerry.close();
}
}
import java.util.*;
public class Around0521 {
public static void main(String args[]) throws IOException{
FileReader inputjerry=new FileReader("940301.SM");
BufferedReader binputjerry=new BufferedReader(inputjerry);
// System.out.print("(迴文判斷)請輸入字母或數字:");
String s1=binputjerry.readLine();
String s2="";
for (int i=s1.length();i>0;i--){
char ch =s1.charAt(i-1);
s2=s2+ch;
}
if (s1.equals(s2)) System.out.println(s1+" is a palindrome"); //如果s1=s2
else System.out.println(s1+" is not a palindrome");
FileWriter outputjerry=new FileWriter("940301.T01");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
if (s1.equals(s2)) boutputjerry.write(String.valueOf(s1+" is a palindrome"));
else boutputjerry.write(String.valueOf(s1+" is not a palindrome"));
boutputjerry.flush();
boutputjerry.close();
}
}
長整數
mport java.io.*;
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
mport java.io.*;
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.util.*;
// inputtext.txt 檔案內容 COFFEE 50 4
// 從檔案讀入一列字串,讀入50 和 4 相乘再寫入另一檔案
class TestReadWrite0514
{
public static void main(String[] args)
{
String line,item,la,lb;
long num,price,total;
try
{
FileReader inputjerry=new FileReader("inputtext.txt");
BufferedReader binputjerry=new BufferedReader(inputjerry);
line=binputjerry.readLine();
StringTokenizer stline=new StringTokenizer(line, " ");
item=stline.nextToken();
System.out.println(item);
num=Long.parseLong(stline.nextToken()); //利用Long轉換String
System.out.println(num);
price=Long.parseLong(stline.nextToken());
System.out.println(price);
total=price+num;
System.out.println(total);
FileWriter outputjerry=new FileWriter("outputtext.txt");
BufferedWriter boutputjerry=new BufferedWriter(outputjerry);
boutputjerry.write(String.valueOf(total));
boutputjerry.flush();
boutputjerry.close();
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.io.*;
import java.lang.Byte;
import java.util.StringTokenizer;
class TestFile
{
public static void main(String args[])
{
String InFileName;
String OutFileName;
String strLine;
try
{
InFileName=args[0];
//System.out.println(InFileName);
FileReader mdFile = new FileReader(InFileName);
BufferedReader brdFile = new BufferedReader(mdFile);
double s=0;
double x,y ;
for(int a = 0 ; a < 11 ; a++)
{
strLine= brdFile.readLine();
System.out.println(strLine);
x=Double.valueOf(strLine).doubleValue();
s=s+x;
}
y=s/11;
System.out.println(s);
System.out.println(y);
StringTokenizer tokens = new StringTokenizer( InFileName, ".t");
OutFileName = tokens.nextToken() + ".w" + tokens.nextToken();
//System.out.println(OutFileName);
File myfile=new File(OutFileName);
myfile.createNewFile();
FileWriter fos= new FileWriter(OutFileName);
String str=Double.toString(y);
fos.write("平均 : "+str);
fos.flush();
fos.close();
}
catch (Exception e)
{
}
}
}
import java.lang.Byte;
import java.util.StringTokenizer;
class TestFile
{
public static void main(String args[])
{
String InFileName;
String OutFileName;
String strLine;
try
{
InFileName=args[0];
//System.out.println(InFileName);
FileReader mdFile = new FileReader(InFileName);
BufferedReader brdFile = new BufferedReader(mdFile);
double s=0;
double x,y ;
for(int a = 0 ; a < 11 ; a++)
{
strLine= brdFile.readLine();
System.out.println(strLine);
x=Double.valueOf(strLine).doubleValue();
s=s+x;
}
y=s/11;
System.out.println(s);
System.out.println(y);
StringTokenizer tokens = new StringTokenizer( InFileName, ".t");
OutFileName = tokens.nextToken() + ".w" + tokens.nextToken();
//System.out.println(OutFileName);
File myfile=new File(OutFileName);
myfile.createNewFile();
FileWriter fos= new FileWriter(OutFileName);
String str=Double.toString(y);
fos.write("平均 : "+str);
fos.flush();
fos.close();
}
catch (Exception e)
{
}
}
}
import java.io.*;
import java.lang.Byte;
class Myjava0430
{
public static void main(String args[])
{
int x,y,z;
x=Integer.parseInt(args[0]);
y=Integer.parseInt(args[1]);
z=x+y;
//Byte b=new Byte("2");
try
{
File myfile=new File("mytest.txt");
myfile.createNewFile();
FileOutputStream fos=new FileOutputStream(myfile);
PrintStream ps=new PrintStream(fos);
ps.println(z);
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
import java.lang.Byte;
class Myjava0430
{
public static void main(String args[])
{
int x,y,z;
x=Integer.parseInt(args[0]);
y=Integer.parseInt(args[1]);
z=x+y;
//Byte b=new Byte("2");
try
{
File myfile=new File("mytest.txt");
myfile.createNewFile();
FileOutputStream fos=new FileOutputStream(myfile);
PrintStream ps=new PrintStream(fos);
ps.println(z);
}
catch(Exception e)
{
System.out.println("Exception");
}
}
}
2010年4月9日 星期五
三角形和長方形的面積
class Myjava
{
public static void main(String[] args)
{
int w,u;
String s1,s2;
int a , b;
a=3;
b=4;
Triangel maxine =new Triangel();
Ractangle maxine1 =new Ractangle();
s1=args[0];
s2=args[1];
u=maxine.add(s1,s2);
w=maxine1.add(s1,s2);
System.out.println(u);
System.out.println(w);
}
}
class Triangel
{
Triangel ()
{
}
static int add(int s1, int s2)
{
int x,y,z;
x=s1;
y=s2;
z=(x*y)/2;
//System.out.println(z);
return z ;
}
static int add(String s1,String s2)
{
int x,y,z;
x=Integer.parseInt(s1);
y=Integer.parseInt(s2);
z=(x*y)/2;
//System.out.println(z);
return z ;
}
}
class Ractangle
{
Ractangle()
{
}
static int add(int s1, int s2)
{
int x,y,z;
x=s1;
y=s2;
z=(x*y);
//System.out.println(z);
return z ;
}
static int add(String s1,String s2)
{
int x,y,z;
x=Integer.parseInt(s1);
y=Integer.parseInt(s2);
z=(x*y);
//System.out.println(z);
return z ;
}
}
{
public static void main(String[] args)
{
int w,u;
String s1,s2;
int a , b;
a=3;
b=4;
Triangel maxine =new Triangel();
Ractangle maxine1 =new Ractangle();
s1=args[0];
s2=args[1];
u=maxine.add(s1,s2);
w=maxine1.add(s1,s2);
System.out.println(u);
System.out.println(w);
}
}
class Triangel
{
Triangel ()
{
}
static int add(int s1, int s2)
{
int x,y,z;
x=s1;
y=s2;
z=(x*y)/2;
//System.out.println(z);
return z ;
}
static int add(String s1,String s2)
{
int x,y,z;
x=Integer.parseInt(s1);
y=Integer.parseInt(s2);
z=(x*y)/2;
//System.out.println(z);
return z ;
}
}
class Ractangle
{
Ractangle()
{
}
static int add(int s1, int s2)
{
int x,y,z;
x=s1;
y=s2;
z=(x*y);
//System.out.println(z);
return z ;
}
static int add(String s1,String s2)
{
int x,y,z;
x=Integer.parseInt(s1);
y=Integer.parseInt(s2);
z=(x*y);
//System.out.println(z);
return z ;
}
}
2010年4月2日 星期五
class Myjava
{
public static void main(String[] args)
{
int w,u;
String s1,s2;
int a , b;
a=7;
b=3;
u=add(a,b);
s1=args[0];
s2=args[1];
w=add(s1,s2);
System.out.println(s1);
System.out.println(s2);
System.out.println(u);
System.out.println(w);
}
static int add(String s1, String s2)
{
int x,y,z;
x=Integer.parseInt(s1);
y=Integer.parseInt(s2);
z=x+y;
//System.out.println(z);
return z ;
}
static int add(int a,int b)
{
int u;
u=a+b;
//System.out.println(u);
return u ;
}
}
{
public static void main(String[] args)
{
int w,u;
String s1,s2;
int a , b;
a=7;
b=3;
u=add(a,b);
s1=args[0];
s2=args[1];
w=add(s1,s2);
System.out.println(s1);
System.out.println(s2);
System.out.println(u);
System.out.println(w);
}
static int add(String s1, String s2)
{
int x,y,z;
x=Integer.parseInt(s1);
y=Integer.parseInt(s2);
z=x+y;
//System.out.println(z);
return z ;
}
static int add(int a,int b)
{
int u;
u=a+b;
//System.out.println(u);
return u ;
}
}
2010年3月26日 星期五
2010年3月19日 星期五
2010年2月25日星期四
public class HolloWorld {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,x;
double pi;
pi=Math.PI;
System.out.println("pi="+pi);
System.out.println("cos(0)="+Math.cos(0));
System.out.println("cos(pi/4)="+Math.cos(pi/4));
System.out.println("cos(pi/2)="+Math.cos(pi/2));
System.out.println("cos(3pi/2)="+Math.cos(3*pi/2));
System.out.println("cos(2pi)="+Math.cos(2*pi));
System.out.println("sin(0)="+Math.sin(0));
System.out.println("sin(pi/4)="+Math.sin(pi/4));
System.out.println("sin(pi/2)="+Math.sin(pi/2));
System.out.println("sin(3*pi/2)="+Math.sin(3*pi/2));
System.out.println("sin(2*pi)="+Math.cos(2*pi));
}
}
pi=3.141592653589793
cos(0)=1.0
cos(pi/4)=0.7071067811865476
cos(pi/2)=6.123233995736766E-17
cos(3pi/2)=-1.8369701987210297E-16
cos(2pi)=1.0
sin(0)=0.0
sin(pi/4)=0.7071067811865475
sin(pi/2)=1.0
sin(3*pi/2)=-1.0
sin(2*pi)=1.0
public class HolloWorld {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,x;
double pi;
pi=Math.PI;
System.out.println("pi="+pi);
System.out.println("cos(0)="+Math.cos(0));
System.out.println("cos(pi/4)="+Math.cos(pi/4));
System.out.println("cos(pi/2)="+Math.cos(pi/2));
System.out.println("cos(3pi/2)="+Math.cos(3*pi/2));
System.out.println("cos(2pi)="+Math.cos(2*pi));
System.out.println("sin(0)="+Math.sin(0));
System.out.println("sin(pi/4)="+Math.sin(pi/4));
System.out.println("sin(pi/2)="+Math.sin(pi/2));
System.out.println("sin(3*pi/2)="+Math.sin(3*pi/2));
System.out.println("sin(2*pi)="+Math.cos(2*pi));
}
}
pi=3.141592653589793
cos(0)=1.0
cos(pi/4)=0.7071067811865476
cos(pi/2)=6.123233995736766E-17
cos(3pi/2)=-1.8369701987210297E-16
cos(2pi)=1.0
sin(0)=0.0
sin(pi/4)=0.7071067811865475
sin(pi/2)=1.0
sin(3*pi/2)=-1.0
sin(2*pi)=1.0
2010年3月12日 星期五
java1
第三週 2010/03/12
講義書200元(多退少補)
從嘗試錯誤中學習Java程式寫作
Learning Java from Error Messages
許志宇
序
『從嘗試錯誤中學習Java程式寫作』這一本教材是一種全新的Java教學法,克服同學懼怕學習程式時,面對錯誤產生時的茫然無知與手足無措,直接從嘗試錯誤中學習Java程式寫作。一般的Java書的寫法有條理與結構,但是學生無法自習而學會Java程式設計,因為在錯誤產生的時候,一般書本並沒有告訴您該如何解決,因此初學者在茫然無知手足無措的情況下,只好放棄學習Java程式設計。
『從錯誤中學習、從失敗裡成功、從跌倒處站立』是一種人生觀也可當成學習的法則,學習任何學問都要不怕失敗越挫越勇,終究會有爐火純青而登峰造極的境地。
網路資源下載並安裝Java的軟體開發環境。
設定環境變數。
熟悉命令提示字元視窗程式
編輯與執行java第一個程式。
了解設計Java程式的步驟。
在獲得的錯誤訊息中,提供修改程式的提示。
了解Java程式的一個最簡單的形式。
除了只有一個class 可以有 main()方法外,其他的類別只能有一個和類別名稱一樣的方法,此方法稱之為建構子。
要電腦聽命作事的步驟要放在建構子中。
請記住名言『作事需要方法』。
利用上↑下↓鍵可以重複使用在命令提示字元已經打入的指令。
作業
1. 在main()方法中以System.out.printline 畫一棵聖誕樹。
2. 寫一個顯示字串的類別程式並含有建構子,在main()方法中實作物件,畫一棵聖誕樹。
class myjava
{
public static void main(String[] args)
{
System.out.println(" *");System.out.println("***");System.out.println("****");System.out.println(" * ");System.out.println(" * ");
}
}
講義書200元(多退少補)
從嘗試錯誤中學習Java程式寫作
Learning Java from Error Messages
許志宇
序
『從嘗試錯誤中學習Java程式寫作』這一本教材是一種全新的Java教學法,克服同學懼怕學習程式時,面對錯誤產生時的茫然無知與手足無措,直接從嘗試錯誤中學習Java程式寫作。一般的Java書的寫法有條理與結構,但是學生無法自習而學會Java程式設計,因為在錯誤產生的時候,一般書本並沒有告訴您該如何解決,因此初學者在茫然無知手足無措的情況下,只好放棄學習Java程式設計。
『從錯誤中學習、從失敗裡成功、從跌倒處站立』是一種人生觀也可當成學習的法則,學習任何學問都要不怕失敗越挫越勇,終究會有爐火純青而登峰造極的境地。
網路資源下載並安裝Java的軟體開發環境。
設定環境變數。
熟悉命令提示字元視窗程式
編輯與執行java第一個程式。
了解設計Java程式的步驟。
在獲得的錯誤訊息中,提供修改程式的提示。
了解Java程式的一個最簡單的形式。
除了只有一個class 可以有 main()方法外,其他的類別只能有一個和類別名稱一樣的方法,此方法稱之為建構子。
要電腦聽命作事的步驟要放在建構子中。
請記住名言『作事需要方法』。
利用上↑下↓鍵可以重複使用在命令提示字元已經打入的指令。
作業
1. 在main()方法中以System.out.printline 畫一棵聖誕樹。
2. 寫一個顯示字串的類別程式並含有建構子,在main()方法中實作物件,畫一棵聖誕樹。
class myjava
{
public static void main(String[] args)
{
System.out.println(" *");System.out.println("***");System.out.println("****");System.out.println(" * ");System.out.println(" * ");
}
}
訂閱:
文章 (Atom)