25-01-2010, 12:21 AM
|
#28
|
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
|
رد: طلاب البرمجه برابغ
الحل النهائي للأسامينت الرابع والخامس ( بالإعتماد على تعبئة أخونا AdSs_11 للطرق ( كتابة القوانين )) :
الأسايمن الرابع :
كود PHP:
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() { int Beaufort = (int) (getKilometerPerHour() / 3.01) ; double b = 3/2 ; Beaufort = (int) Math.pow(Beaufort,b); return Beaufort; } } 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()); } }
الأسايمنت الخامس :
كود PHP:
import java.io.*; 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() { int Beaufort = (int) (getKilometerPerHour() / 3.01) ; double b = 3/2 ; Beaufort = (int) Math.pow(Beaufort,b); return Beaufort; } } class JavaApplication3 { public static void main(String[] args) { Scanner s=new Scanner(System.in); double [] data = {1}; /* Read fromFile */ try { // Calculat the Number in the File --- File file = new File("C:\\windspeed.data"); FileInputStream fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); DataInputStream dis = new DataInputStream(bis); int size = 0; while (dis.available() != 0) { dis.readLine(); size++; } dis.close(); // Fill array --- fis = new FileInputStream(file); bis = new BufferedInputStream(fis); dis = new DataInputStream(bis); data = new double[size]; for (int i = 0; i < size ; i++) { data[i] = Double.parseDouble(dis.readLine()); } } catch (IOException ex) { System.out.println(ex.toString()); } //--------------------------------------- int i; boolean cont=true; int choice; WindSpeed [] w=new WindSpeed[data.length]; for(i=0;i<data.length;i++) { w[i]=new WindSpeed(data[i]); } while(cont) { System.out.println("1) All wind speeds in knots"); System.out.println("2) All wind speeds in Beauford scale"); System.out.println("3) All wind speeds that are considered as calm wind"); System.out.println("4) All wind speeds that are considered as turbulent (wind storm)"); System.out.println("5) The average wind speed in km/h, knote and Beauford"); System.out.println("6) Quit the program"); choice=s.nextInt(); switch(choice) { case 1: System.out.println("All wind speeds in knots"); for(i=0;i<w.length;i++) { System.out.println(w[i].getKnots()); } break; case 2: System.out.println("All wind speeds in Beauford scale"); for(i=0;i<w.length;i++) { System.out.println(w[i].getKnots()); } break; case 3: System.out.println("All wind speeds that are considered as calm wind"); for(i=0;i<w.length;i++) { if(w[i].IsCalm()) System.out.println(w[i].getKnots()); } break; case 4: System.out.println("All wind speeds that are considered as turbulent (wind storm)"); for(i=0;i<w.length;i++) { if(w[i].IsWindStorm()) System.out.println(w[i].getKnots()); } break; case 5: System.out.println("The average wind speed in km/h, knote and Beauford"); double sum=0,avg; for(i=0;i<w.length;i++) { sum=sum+w[i].getKnots(); } avg=sum/w.length; System.out.println("Average = "+avg); break; case 6: cont=false; break; default: System.out.println("Error select from (1 to 6 only)"); } } } }
بالتوفيق ..
|
|
سبحان الله وبحمد ,,, سبحان الله العظيم الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه . اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.
|
|
|
|