الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ارجو المساعدة في اضافة كود

مغلق
بدأه ابو اوس2008 في 31 أكتوبر 2007 · 3 رد · 549 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لدي واجب ولم اعرف ان اعمل اي شيء به ، ارجو المساعده وهو كما يلي

Modify the Bisection_Applet5.java so that it tries a range of angles from 10 to 80 degrees and reports the angle that results in the longest shot. Use the Histogram class to record the distribution of shot distances and then print out the values from the histogram.

علما بان ملف Bisection_Applet5.java في المرفقات

ارجو المساعدة حيث انني لم اعرف اين اعدل او كيفية التعديل

Bisection_Applet5.zip

#2
ابو اوس2008 كتب:
السلام عليكم

لدي واجب ولم اعرف ان اعمل اي شيء به ، ارجو المساعده وهو كما يلي

Modify the Bisection_Applet5.java so that it tries a range of angles from 10 to 80 degrees and reports the angle that results in the longest shot. Use the Histogram class to record the distribution of shot distances and then print out the values from the histogram.

علما بان ملف Bisection_Applet5.java في المرفقات

ارجو المساعدة حيث انني لم اعرف اين اعدل او كيفية التعديل

السلام عليكم

زملائي لا اريد الحل ، بقدر ما اريد مناقشة مثل هذا النوع من البرمجيات ، المشكلة الاساسية التي اواجهها هو كيفية اضافة الفترات حيث بامكاني تقسيمها الى مجموعات الفترة 10- 80

#3

السلام عليكم

انتظر منكم المساعدة والشرح ، ولكم جزيل الشكر

#4

السلام عليكم

قمت بالتعديل كما اسفل المشاركة ، ولكن للاسف الشديد ااعطى رسالة وجود اخطاء

الاخطاء التي ظهرت :-

C:\Program Files\Java\jdk1.5.0_08\bin>javac Bisection_Applet5.java

Bisection_Applet5.java:74: ';' expected

double f_method(double x)

^

1 error

تعديل الكود

// "Java Tech"

// Code provided with book for educational purposes only.

// No warranty or guarantee implied.

// This code freely available. No copyright claimed.

// 2003

//

// A demonstration of the Bisection root finding technique.

// Start from the _Applet5 shell.

public class Bisection_Applet5 extends java.applet.Applet

{

// Put property data between these lines

//------------------------------------------------

// Data for a ballistic trajectory at a given angle

double tan = 0;

double cos = 0;

double g = 9.8; // m/s^2

double v0 = 100; // m/s

//------------------------------------------------

public void init()

{

// Put code between this line

//------------------------------------------------

double tan = Math.tan(Math.PI*i / 180);

double cos = Math.cos(Math.PI*i / 180);

double xl = 0.0;

double xh = 1.0;

double xm = 0.5;

double step = 1.0;

double dif = 1.0;

double maxSteps = 50000000;

// double tol = 1.0E-5;

double tol = 0;

int numSteps = 0;

for(int i =10 ; i<81;i++ ){

do

{

if( f_method(xl) * f_method(xh) > 0)

{

xl += step;

xh += step;

} else

{

xm = (xh+xl)/2.0;

if( f_method(xl) * f_method(xm) < 0)

{ // Root on lower half

xh = (xm+xl)/2.0;

} else

{ // Root on upper half

xl = xm;

xh = (xh+xl)/2.0;

}

dif = Math.abs(f_method(xm));

step = xh-xl;

}

numSteps++;

} while ( dif > tol && numSteps < maxSteps);

System.out.println("After steps ="+numSteps);

System.out.println("Last step size = "+step);

System.out.println("Root x = "+xm+

" within tolerance ="+dif);

//------------------------------------------------

// and this line.

}

// Put a method code here.

// Change the name to something meaningful

// to its task.

double f_method(double x)

{

// Put code between this line

//------------------------------------------------

double val = x*tan - (0.5*g*x*x)/(v0*v0*cos*cos); ;

return val;

//------------------------------------------------

// and this line.

}

// Paint message in Applet window.

public void paint(java.awt.Graphics g)

{

g.drawString("Bisection_Applet5",10,20);

}

// Can also run this program as an application.

// No windowing needed so just run the applets

// init() function.

public static void main(String [] args)

{

Bisection_Applet5 obj = new Bisection_Applet5();

obj.init();

}

}

}

هذا الموضوع مغلق.

مواضيع مشابهة