عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 22-02-2012, 10:59 PM   #27

мαѕooяy

لآ يَستحقْ الكثَيرْ ::

الصورة الرمزية мαѕooяy

 
تاريخ التسجيل: Apr 2009
التخصص: Cs <3
نوع الدراسة: إنتظام
المستوى: الخامس
الجنس: أنثى
المشاركات: 6,263
افتراضي رد: }{ تعالو نفهم بعض الsheet }{....برمجة 2

المشاركة الأصلية كتبت بواسطة moon alharbi مشاهدة المشاركة
ياليت احد يساعدني




average must be a static method since it is called from the static method main.
1. Compile and run the program. You must use the -source 1.5 option in your compile command.

هنـآ مجرد تسوي رن للبرنامج ،.. وتشوفي الأوت بوت

2. Add a call to find the average of a single integer, say 13. Print the result of the call.

يقلك نآدي الميثود حقت الأفرج مرة ثانية لكن هالمرة آرسلي لهـآ رقم وحيد انتجر وليكن مثال 13

3. Add a call with an empty parameter list and print the result. Is the behavior what you expected?

يقلك مرة ثانية نادي ميثود افرج ، لكن بدون أي شيء يعني لما تناديهـآ لاتعطيهـآ قيم وشوفي ايش يصير

4. Add an interactive part to the program. Ask the user to enter a sequence of at most 20 nonnegative integers. Your program should have a loop that reads the integers into an array and stops when a negative is entered (the negative number should not be stored). Invoke the average method to find the average of the integers in the array (send the array as the parameter). Does this work?


هنـآ ،.. عرفي مصفوفة جديدهـ ،
وآسمحلي لليوزر يدخل أرقاام فيهـآ أكثررر شيء 20 رقم مآيقدر يدخل أكثر من كدـآ ،.
طبعا فيهـآ اف الشرطية انو لازم اقل من 20 ،.
ثاني شيء يقلك .. لازم تشرطي عليه كل الارقام موجبببة ، ..
و يبدأ يخزن بالمصفوفة الأرقام الموجبة ،.
لو واحد مايبغى يدخل 20 ،. يبغى بس 10 ارقام ، اذا يوقف اللوب بانه يدخل رقم سالب ،..
والرقم السالب مآيخزنه ....


5. Add a method minimum that takes a variable number of integer parameters and returns the minimum of the parameters. Invoke your method on each of the parameter lists used for the average function.


هنـآ ياعسل اعمل ميثود جديدة ، وعرفيهـآ،..
و أعملي منـآدــآه لهـآ ، لكل البارميتر اللي فوق
يعني شوفي بالكود اول مناداة كانت فيهـآ 3 ارقام
هي نفسهـآ آرجعي سويهـآ لكن للميثود المينمم اللي حتسويهـآ
ونفسه للثانية
و نفسه للرقم الانتجر اللي عملتيه يعني كل المنادات اللي للأفرج أعمليهـآ بنفس البارميتر للمينمم ،.
وطلعي النواتج

بس

كود:
//*
// parameters.java
//
// illustrates the concept of a variable parameter list.
//*
import java.util.scanner;
public class parameters
{
//-----------------------------------------------
// calls the average and minimum methods with
// different numbers of parameters.
//-----------------------------------------------
public static void main(string[] args)
{
double mean1, mean2;
mean1 = average(42, 69, 37);
mean2 = average(35, 43, 93, 23, 40, 21, 75);
system.out.println ("mean1 = " + mean1);
system.out.println ("mean2 = " + mean2);
}
//----------------------------------------------
// returns the average of its parameters.
//----------------------------------------------
public static double average (int ... List)
{
double result = 0.0;
if (list.length != 0)
{
int sum = 0;
for (int num: List)
sum += num;
result = (double)sum / list.length;
}
return result;
}
}


ممنوع وضع الاكواد ،.. بس شرحتلك المطلوب ان شاء الله تقدري تنفذيه

 

توقيع мαѕooяy  

 





,,,
مازال يراودني يقين
بأن هناك شيء ينتظرني
بعد الصبر ليبهرني
وينسيني مرارة الأمس
,,,



 

мαѕooяy غير متواجد حالياً   رد مع اقتباس