herrDeng網內搜尋

自訂搜尋

Ads

2011年6月16日 星期四

Ex1

請宣告2個double型態之變數x、y,其值分別為6、2:


(1)自訂函式add()可傳回(x+y)之值 ,並於main印出回傳值。


(2)自訂函式sub()可傳回(x-y) 之值,並於main印出回傳值。


(3)自訂函式mul()可傳回(x*y)之值 ,並於main印出回傳值。


(4)自訂函式div()可傳回(x/y)之值 ,並於main印出回傳值。

21 則留言:

B9933100 提到...

public class ex1 {
static double add(double x,double y)
{
return x+y;
}
static double sub(double x,double y)
{
return x-y;
}
static double mul(double x,double y)
{
return x*y;
}
static double div(double x,double y)
{
return x/y;
}
public static void main(String[] args) {
double x=6,y=2;
System.out.println("x+y="+add(x,y));
System.out.println("x-y="+sub(x,y));
System.out.println("x*y="+mul(x,y));
System.out.println("x/y="+div(x,y));
}
}

B9933061 提到...

class EX1{
static double add(double x, double y )
{
return x+y;
}
static double sub(double x, double y )
{
return x-y;
}
static double mul(double x, double y )
{
return x*y;
}
static double div(double x, double y )
{
return x/y;
}

public static void main(String [] argv){
double x=6, y=2;

System.out.println("x+y="+add(x,y));
System.out.println("x+y="+sub(x,y));
System.out.println("x+y="+mul(x,y));
System.out.println("x+y="+div(x,y));
}
}

b9733202 提到...

class test
{
public static double add(double x,double y)
{
return x+y ;
}
public static double sub(double x,double y)
{
return x-y ;
}
public static double mul(double x,double y)
{
return x*y ;
}
public static double div(double x,double y)
{
return x/y ;
}
public static void main(String[] args)
{
double x = 6;
double y = 2;
System.out.println(x+"+"+y+"="+add(x,y));
System.out.println(x+"-"+y+"="+sub(x,y));
System.out.println(x+"*"+y+"="+mul(x,y));
System.out.println(x+"/"+y+"="+div(x,y));
}
}

A9933058 提到...

public class y2
{
public static double add(double a, double b)
{
return a+b;
}
public static double sub(double a, double b)
{
return a-b;
}
public static double mul(double a, double b)
{
return a*b;
}
public static double div(double a, double b)
{
return a/b;
}
public static void main(String[] args)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

a9933056 提到...

public class razer
{
public static double dog(double a, double b)
{
return a+b;
}
public static double cat(double a, double b)
{
return a-b;
}
public static double banana(double a, double b)
{
return a*b;
}
public static double apple(double a, double b)
{
return a/b;
}
public static void main(String[] args)
{
double x=7,y=5;
System.out.println(dog(x,y));
System.out.println(cat(x,y));
System.out.println(banana(x,y));
System.out.println(apple(x,y));
}
}

A9933059 提到...

public class apple
{
public static double add(double a, double b)
{
return a+b;
}
public static double sub(double a, double b)
{
return a-b;
}
public static double mul(double a, double b)
{
return a*b;
}
public static double div(double a, double b)
{
return a/b;
}
public static void main(String[] args)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

b9933097 提到...

class ex1{
public static double add(double a,double b)
{
return a+b;
}
public static double sub(double a,double b)
{
return a-b;
}
public static double mul(double a,double b)
{
return a*b;
}
public static double div(double a,double b)
{
return a/b;
}
public static void main(String[] arg)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));

}
}

b9933110 提到...

class ex1{
public static double add(double a,double b)
{
return a+b;
}
public static double sub(double a,double b)
{
return a-b;
}
public static double mul(double a,double b)
{
return a*b;
}
public static double div(double a,double b)
{
return a/b;
}
public static void main(String[]arg)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));

}

}

b9933094 提到...

public class test
{
public static double add(double a, double b)


{
return a+b;
}
public static double sub(double a, double b)
{
return a-b;
}
public static double mul(double a, double b)
{
return a*b;
}
public static double div(double a, double b)
{
return a/b;
}
public static void main(String[]args)
{
double x=6, y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

B9933085 提到...

public class Ex1 {
public static double add (double x,double y)
{return x+y;}
public static double sub (double x,double y)
{return x-y;}
public static double mul (double x,double y)
{return x*y;}
public static double div (double x,double y)
{return x/y;}
public static void main(String[] args) {
double x=6,y=2;
System.out.println(add (x,y));
System.out.println(sub (x,y));
System.out.println(mul (x,y));
System.out.println(div (x,y));
}
}

b9933064 提到...

class ex1{
public static double add(double a,double b)
{
return a+b;
}
public static double sub(double a,double b)
{
return a-b;
}
public static double mul(double a,double b)
{
return a*b;
}
public static double div(double a,double b)
{
return a/b;
}
public static void main(String[]arg)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));

}

}

B9933078 提到...

class ex1{
public static double add(double a,double b)
{
return a+b;
}
public static double sub(double a,double b)
{
return a-b;
}
public static double mul(double a,double b)
{
return a*b;
}
public static double div(double a,double b)
{
return a/b;
}
public static void main(String[]arg)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));

}

}

A9933058 提到...

public class y2
{
public static double add(double a, double b)
{
return a+b;
}
public static double sub(double a, double b)
{
return a-b;
}
public static double mul(double a, double b)
{
return a*b;
}
public static double div(double a, double b)
{
return a/b;
}
public static void main(String[] args)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

B9933066 提到...

class EX1{
static double add(double x, double y )
{
return x+y;
}
static double sub(double x, double y )
{
return x-y;
}
static double mul(double x, double y )
{
return x*y;
}
static double div(double x, double y )
{
return x/y;
}

public static void main(String [] argv){
double x=6, y=2;

System.out.println("x+y="+add(x,y));
System.out.println("x+y="+sub(x,y));
System.out.println("x+y="+mul(x,y));
System.out.println("x+y="+div(x,y));
}
}

B9933106 提到...

class EX1{
static double add(double x, double y )
{
return x+y;
}
static double sub(double x, double y )
{
return x-y;
}
static double mul(double x, double y )
{
return x*y;
}
static double div(double x, double y )
{
return x/y;
}

public static void main(String [] argv){
double x=6, y=2;

System.out.println("x+y="+add(x,y));
System.out.println("x+y="+sub(x,y));
System.out.println("x+y="+mul(x,y));
System.out.println("x+y="+div(x,y));
}
}

B9933065 提到...

class EX1{
public static double add(double a,double b){
return a+b;
}
public static double sub(double c,double d){
return c-d;
}
public static double mul(double e,double f){
return e*f;
}
public static double div(double g,double h){
return g/h;
}
public static void main(String [] args){
double x=6;
double y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

B9933068 提到...

class aaa
{
public static double add(double x, double y)
{
return x+y;
}
public static double sub(double x, double y)
{
return x-y;
}
public static double mul(double x, double y)
{
return x*y;
}
public static double div(double x, double y)
{
return x/y;
}
public static void main(String [] arg)
{
double x=6;
double y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

B9933108 提到...

class EX1{
public static double add(double a,double b){
return a+b;
}
public static double sub(double c,double d){
return c-d;
}
public static double mul(double e,double f){
return e*f;
}
public static double div(double g,double h){
return g/h;
}
public static void main(String [] args){
double x=6;
double y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

b9933075 提到...

class ex1{
public static double add(double a,double b)
{
return a+b;
}
public static double sub(double a,double b)
{
return a-b;
}
public static double mul(double a,double b)
{
return a*b;
}
public static double div(double a,double b)
{
return a/b;
}
public static void main(String[]arg)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));

}

}

B9933072 提到...

class EX1{
static double add(double x, double y )
{
return x+y;
}
static double sub(double x, double y )
{
return x-y;
}
static double mul(double x, double y )
{
return x*y;
}
static double div(double x, double y )
{
return x/y;
}

public static void main(String [] argv){
double x=6, y=2;

System.out.println("x+y="+add(x,y));
System.out.println("x+y="+sub(x,y));
System.out.println("x+y="+mul(x,y));
System.out.println("x+y="+div(x,y));
}
}

B9933116 提到...

class ex1{
public static double add(double a,double b)
{
return a+b;
}
public static double sub(double a,double b)
{
return a-b;
}
public static double mul(double a,double b)
{
return a*b;
}
public static double div(double a,double b)
{
return a/b;
}
public static void main(String[]arg)
{
double x=6,y=2;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));

}

}

Related Posts Plugin for WordPress, Blogger...

熱門文章