07-05-2010, 10:15 PM
|
#3
|
تاريخ التسجيل: Feb 2010
التخصص: علومْ حآسبَآتّ CS
نوع الدراسة: إنتظام
المستوى: السابع
الجنس: أنثى
المشاركات: 246
|
رد: طالبات استاذه سمية البرادعيcpcs203
كود:
import java.util.*;
import java.lang.*;
class BodyMass{
private String name;
private double tall;
private double weight;
public double temp;
//---------------------------------------
//constractore method;
public BodyMass(){
name=" ";
tall=0.00;
weight=0.00;
}
//-----------------------------------
public void inputData(){
Scanner scan=new Scanner(System.in);
System.out.println("Enter the person name :");
name=scan.nextLine();
System.out.println("Enter your Body weight in kg :");
tall=scan.nextDouble();
System.out.println("Enter your Body tall in m :");
weight=scan.nextDouble();
}
//---------------------------
public void cal_bodymass(){
double temp=(weight/Math.pow(tall,2));
System.out.println(temp);
if(temp<20)
System.out.println("your weight is less than normal ");
if(temp>20&&temp<25)
System.out.println(" your weight is normal");
if(temp>25&&temp<30)
System.out.println("your person suffering from an increase in weight:");
if(temp>30&&temp<40)
System.out.println("your a danger mark for obese person");
if(temp>=40)
System.out.println("your obesity and has a problems in his health ");
else
System.out.println("these results shows incorrect of Body Mass calculation"); }
public String toString(){String s=("your name "+name+"\nyour tall"+tall+"\nyour weight"+weight);
return s;}
}
كود:
import java.util.*;
import java.lang.*;
class TestBMI{
public static void main(String []args){
BodyMass bodymass=new BodyMass();
String Ans;
Scanner scanner=new Scanner(System.in);
do{
System.out.println("Name of Person: ");
bodymass.inputData();
System.out.println(" Your Body Mass is :");
bodymass.cal_bodymass();
bodymass.toString();
System.out.println("Do you want to continue [y/n]:");
Ans=scanner.next();
}while(Ans.equalsIgnoreCase("y"));
}
}
|
|
|
|
|