public class Practise {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(args[0]);
System.out.println(args[1]);
System.out.println(Integer.parseInt(args[0])+Integer.parseInt(args[1]));
}
}
1.使用args[],來輸入字元
2.再使用Integer.parseInt()把字元轉換成整數
3.再將兩個整數相加,後印出
2010年3月21日 星期日
2010年3月19日 星期五
Java 第一堂課
下載JAVA:載點
下載Eclipse:載點
使用方法:
1.先下載JAVA再下載Eclipse,選擇自己要的版本。
2.因為是硬碟版,所以下載好再解壓縮後;點執行檔即可使用。
第一堂課教學內容:
重點:
1.MATH資料庫的呼叫
2.數學運算
public static void main(String[] args) {
int x,y,z;
x=1;
y=3;
z=x+y;
double pi;
pi=Math.cos(0);
System.out.println(pi);
pi=Math.cos(Math.PI/4);
System.out.println(pi);
pi=Math.cos(Math.PI/2);
System.out.println(pi);
pi=Math.cos(Math.PI*3/2);
System.out.println(pi);
pi=Math.cos(Math.PI*2);
System.out.println(pi);
pi=Math.sin(0);
System.out.println(pi);
pi=Math.sin(Math.PI/4);
System.out.println(pi);
pi=Math.sin(Math.PI/2);
System.out.println(pi);
pi=Math.sin(Math.PI*3/2);
System.out.println(pi);
pi=Math.sin(Math.PI*2);
System.out.println(pi);
// TODO Auto-generated method stub
}
2010年3月15日 星期一
web C# array and write
int[] myArray1 = new int[]{3,4,3,5,6,1};
Response.Write(Convert.ToString(myArray1[0]));
Response.Write("////
");
int[] numbers = { 4, 5, 6, 1, 2, 3, -2, -1, 0 };
foreach (int i in numbers)
{
Response.Write(i);
Response.Write("
");
}
int a,b,c,d,f;
f = Convert.ToInt16(TextBox1.Text);
b = f;
d = f;
a = f % 10;
b = b - a;
b = b / 10;
Convert.ToString(b);
Response.Write(b);
Response.Write("
");
c = f % 5;
d = d - c;
d = d / 5;
Convert.ToString(d);
Response.Write(d);
Response.Write("
");
Response.Write(TextBox1.Text);
Response.Redirect(http://www.yahoo.com.tw);
Response.Write(Convert.ToString(myArray1[0]));
Response.Write("////
");
int[] numbers = { 4, 5, 6, 1, 2, 3, -2, -1, 0 };
foreach (int i in numbers)
{
Response.Write(i);
Response.Write("
");
}
int a,b,c,d,f;
f = Convert.ToInt16(TextBox1.Text);
b = f;
d = f;
a = f % 10;
b = b - a;
b = b / 10;
Convert.ToString(b);
Response.Write(b);
Response.Write("
");
c = f % 5;
d = d - c;
d = d / 5;
Convert.ToString(d);
Response.Write(d);
Response.Write("
");
Response.Write(TextBox1.Text);
Response.Redirect(http://www.yahoo.com.tw);
2010年3月14日 星期日
訂閱:
文章 (Atom)