herrDeng網內搜尋

自訂搜尋

Ads

2012年5月24日 星期四

練習524a

請宣告2個float型態之變數x、y,(3,5)
(1)自訂函式add()可傳回(x+y)之值 ,並於main印出回傳值。
(2)自訂函式sub()可傳回(x-y) 之值,並於main印出回傳值。
(3)自訂函式mul()可傳回(x*y)之值 ,並於main印出回傳值。
(4)自訂函式div()可傳回(x/y)之值 ,並於main印出回傳值。
並在main中輸入x ,y後傳入add()、sub()、mul()、div()函式,
接著列印add()、sub()、mul()、div()之回傳值(return value)

24 則留言:

B9733191 提到...

public class test {
public static float add(float a,float b)
{
return a+b;
}
public static void main(String[] args) {
float a, b;
a=3;
b=5;
System.out.println("a+b="+add(a,b));

}

}

B10033015 提到...

/*
請宣告2個float型態之變數x、y,(3,5)
(1)自訂函式add()可傳回(x+y)之值 ,並於main印出回傳值。
(2)自訂函式sub()可傳回(x-y) 之值,並於main印出回傳值。
(3)自訂函式mul()可傳回(x*y)之值 ,並於main印出回傳值。
(4)自訂函式div()可傳回(x/y)之值 ,並於main印出回傳值。
並在main中輸入x ,y後傳入add()、sub()、mul()、div()函式,
接著列印add()、sub()、mul()、div()之回傳值(return value)
*/

import java.util.*;
class test
{
public static float add(float x,float y)
{
return x+y;//(x+y)之值
}
public static float sub(float x,float y)
{
return x-y;//(x-y) 之值
}
public static float mul(float x,float y)
{
return x*y; //(x*y)之值
}
public static float div(float x,float y)
{
return x/y; //(x/y)之值
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));


}
}

B10033005 提到...

public class qq {
static float add(float x,float y)
{
return x+y;
}
static float sub(float x,float y)
{
return x-y;
}

static float mul(float x,float y)
{
return x*y;
}

static float div(float x,float y)
{
return x/y;
}



public static void main(String[] args) {
float x=3,y=5;

float add=add(x,y);
System.out.println(add);
float sub=sub(x,y);
System.out.println(sub);
float mul=mul(x,y);
System.out.println(mul);
float div=div(x,y);
System.out.println(div);



}
}

B10033003 提到...

import java.util.*;
class zz {
public static float add(float x,float y){
return x+y;
}
public static float sub(float x,float y){
return x-y;
}
public static float mul(float x,float y){
return x*y;
}
public static float div(float x,float y){
return x/y;
}
public static void main(String[] args) {
int x=3,y=5;
float add=add(x,y);
System.out.println("加:");
System.out.println(add);
float sub=sub(x,y);
System.out.println("減:");
System.out.println(sub);
float mul=mul(x,y);
System.out.println("乘:");
System.out.println(mul);
float div=div(x,y);
System.out.println("除:");
System.out.println(div);
}
}

B10033017 提到...

import java.util.*;
class BMI
{
public static double BMIcompute(double x,double y)
{
return x*y;
}
public static void main(String [] arg)throws Exception
{
Scanner input=new Scanner(System.in);
System.out.println("x");
System.out.print("");
double m=input.nextDouble();
System.out.println("y");
System.out.print("");
double w=input.nextDouble();
double BMI=BMIcompute (m,w);
System.out.println(BMI);
}
}

b10033027 提到...

import java.util.*;
class top
{
public static double BMIcompute(double x,double y)
{
return x+y;
}
public static void main(String [] arg)throws Exception
{
Scanner input=new Scanner(System.in);
System.out.println("x:");
System.out.print("");
double x=input.nextDouble();
System.out.println("y:");
System.out.print("");
double y=input.nextDouble();
double BMI=BMIcompute (x,y);
System.out.println(BMI);

}
}

B10033035 提到...

import java.util.*;
class zz {
public static float add(float x,float y){
return x+y;
}
public static float sub(float x,float y){
return x-y;
}
public static float mul(float x,float y){
return x*y;
}
public static float div(float x,float y){
return x/y;
}
public static void main(String[] args) {
int x=3,y=5;
float add=add(x,y);
System.out.println("加:");
System.out.println(add);
float sub=sub(x,y);
System.out.println("減:");
System.out.println(sub);
float mul=mul(x,y);
System.out.println("乘:");
System.out.println(mul);
float div=div(x,y);
System.out.println("除:");
System.out.println(div);
}
}

B10033022 提到...

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

B10033052 提到...

import java.util.*;
class hello{
public static float add(float x,float y)
{
return x+y;
}
public static void main(String [] arg)
{
float x=8;
float y=5;
System.out.println(add(x,y));
}
}

B10033014 提到...

import java.util.*;
class pass {
public static float add(float x,float y){
return x+y;
}
public static float sub(float x,float y){
return x-y;
}
public static float mul(float x,float y){
return x*y;
}
public static float div(float x,float y){
return x/y;
}
public static void main(String[] args) {
int x=3,y=5;
float add=add(x,y);
System.out.println("加:");
System.out.println(add);
float sub=sub(x,y);
System.out.println("減:");
System.out.println(sub);
float mul=mul(x,y);
System.out.println("乘:");
System.out.println(mul);
float div=div(x,y);
System.out.println("除:");
System.out.println(div);
}
}

B10033021 提到...

import java.util.*;
class B10033021
{
public static float add(float x,float y)
{
return x+y;
}
public static float sub(float x,float y)
{
return x-y;
}
public static float mul(float x,float y)
{
return x*y;
}
public static float div(float x,float y)
{
return x/y;
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));


}
}

B10033050 提到...

import java.util.*;
class test
{
public static float add(float x,float y)
{
return x+y;//(x+y)之值
}
public static float sub(float x,float y)
{
return x-y;//(x-y) 之值
}
public static float mul(float x,float y)
{
return x*y; //(x*y)之值
}
public static float div(float x,float y)
{
return x/y; //(x/y)之值
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));


}
}

B10033010 提到...

import java.util.*;
class hello{
public static float add(float x,float y)
{
return x+y;
}
public static void main(String [] arg)
{
float x=8;
float y=5;
System.out.println(add(x,y));
}
}

B10033006 提到...

import java.util.*;
class hello{
public static float add(float x,float y)
{
return x+y;
}
public static void main(String [] arg)
{
float x=8;
float y=5;
System.out.println(add(x,y));
}
}

B10033001 提到...

import java.util.*;
class hello{
public static float add(float x,float y)
{
return x+y;
}
public static void main(String [] arg)
{
float x=8;
float y=5;
System.out.println(add(x,y));
}
}

B10033020 提到...

import java.util.*;
class test
{
public static float add(float x,float y)
{
return x+y;//(x+y)之值
}
public static float sub(float x,float y)
{
return x-y;//(x-y) 之值
}
public static float mul(float x,float y)
{
return x*y; //(x*y)之值
}
public static float div(float x,float y)
{
return x/y; //(x/y)之值
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));


}
}

B10033042 提到...

import java.util.*;
class test{
public static float add(float x,float y)
{
return x+y;
}
public static void main(String [] arg)
{
float x=8;
float y=5;
System.out.println(add(x,y));
}
}

b10033016 提到...

import java.util.*;
class a524{
public static float add(float x,float y)
{
return x+y;//(x+y)之值
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
}
}

b10033028 提到...

public class qq {
static float add(float x,float y)
{
return x+y;
}
static float sub(float x,float y)
{
return x-y;
}

static float mul(float x,float y)
{
return x*y;
}

static float div(float x,float y)
{
return x/y;
}



public static void main(String[] args) {
float x=3,y=5;

float add=add(x,y);
System.out.println(add);
float sub=sub(x,y);
System.out.println(sub);
float mul=mul(x,y);
System.out.println(mul);
float div=div(x,y);
System.out.println(div);



}
}

B10033025 提到...

import java.util.*;
class XD
{
public static float add(float x,float y)
{
return x+y;//(x+y)之值
}
public static float sub(float x,float y)
{
return x-y;//(x-y) 之值
}
public static float mul(float x,float y)
{
return x*y; //(x*y)之值
}
public static float div(float x,float y)
{
return x/y; //(x/y)之值
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
System.out.println(sub(x,y));
System.out.println(mul(x,y));
System.out.println(div(x,y));
}
}

B10033011 提到...

import java.util.*;
class hello{
public static float add(float x,float y)
{
return x+y;//(x+y)之值
}
public static void main(String [] arg)
{
float x=3;
float y=5;
System.out.println(add(x,y));
}
}

B10033004 提到...

import java.util.*;
class top
{
public static double BMIcompute(double x,double y)
{
return x+y;
}
public static void main(String [] arg)throws Exception
{
Scanner input=new Scanner(System.in);
System.out.println("x:");
System.out.print("");
double x=input.nextDouble();
System.out.println("y:");
System.out.print("");
double y=input.nextDouble();
double BMI=BMIcompute (x,y);
System.out.println(BMI);

}
}

B10033056 提到...

import java.util.*;
class top
{
public static double BMIcompute(double x,double y)
{
return x+y;
}
public static void main(String [] arg)throws Exception
{
Scanner input=new Scanner(System.in);
System.out.println("x:");
System.out.print("");
double x=input.nextDouble();
System.out.println("y:");
System.out.print("");
double y=input.nextDouble();
double BMI=BMIcompute (x,y);
System.out.println(BMI);

}
}

B9733205 提到...

import java.util.*;
class TED{
public static float add(float x,float y){
return x+y;
}
public static float sub(float x,float y){
return x-y;
}
public static float mul(float x,float y){
return x*y;
}
public static float div(float x,float y){
return x/y;
}
public static void main(String[] args) {
int x=3,y=5;
float add=add(x,y);
System.out.println("加:");
System.out.println(add);
float sub=sub(x,y);
System.out.println("減:");
System.out.println(sub);
float mul=mul(x,y);
System.out.println("乘:");
System.out.println(mul);
float div=div(x,y);
System.out.println("除:");
System.out.println(div);
}
}

Related Posts Plugin for WordPress, Blogger...

熱門文章