حل الأسايمنت الرابع بالإعتماد على الحل الذي بالأعلى ( حل أخوي adss_11 ) :
كود PHP:
[left]import java.util.scanner;
class windspeed
{
double speed;
int b = 0;
public windspeed(double v)
{
speed=v;
}
public double getkilometerperhour()
{
return speed;
}
public boolean iswindstorm()
{
if(speed>120)
return true;
else
return false;
}
public boolean iscalm()
{
if(speed<2)
return true;
else
return false;
}
public double getknots()
{
return (speed/1.852);
}
public int getbeaufort()
{
return b;
}
}
class javaapplication3 {
public static void main(string[] args) {
windspeed ws;
scanner s = new scanner(system.in);
system.out.println("please enter speed : ");
double x = s.nextdouble();
ws = new windspeed(x);
system.out.println("1) wind speeds in knots = " + ws.getknots());
system.out.println("2) wind speeds in beauford scale = " + ws.getbeaufort());
system.out.println("3) wind speeds that is considered as calm wind = " + ws.iscalm());
system.out.println("4) wind speeds that is considered as turbulent (wind storm) = " + ws.iswindstorm());
system.out.println("5) average wind speed in km/h, knote and beauford = " + ws.getkilometerperhour());
}
}
[/left]
أتمنى لكم التوفيق .
والشكر موصول للأخ adss_11 فهو مفتاح الحل .