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

[تنبيه - عنوان غير مناسب : ]سؤال عن String &arrylist..~>> سؤال مهم ارجو المساعده

بدأه كله مستخدم في 27 مايو 2009 · 7 رد · 410 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

لدي سؤال على برنامج الـ "بلو جي" لم اعرف طريقة الحل ولكن حاولت و احتاج اجابته اليوم

فأتمنى منكم المساعده

السؤال هو:

1) Create a Class with the name"MyCollege".

2) Declare aString variable called "myCol" which has the sollowing text in it:-

The College of Information Technology CIT was founded in 2001. The mission of the CIT is to offer solid student centered programs. The CIT was designed so as to bring down the traditional walls that separate departments within a college. All CIT courses are developed and taught using the Blackboard course management system and the entire CIT campus is equipped with wireless internet access

You are required to do the following:

3) Create a method called "counWordShortThan" inside the MyCollege class which is suppose to count the number of words in"var" string variable whose lengths are less than an input value "wordLen"

Public int countWordsShorterThan(String var, int wordLen)

4) in the main () method, call the countWordsShorterThan(myCol,5) to count the number of words in "myCol" string variable whose lengths are less than 5 and print the number on screen.

والحل اللي حاولته هو :

public class MyCollege

{

// instance variables - replace the example below with your own

private String myCol;

private String var;

private String wordLen;

/**

* Constructor for objects of class MyCollege

*/

public MyCollege()

{

// initialise instance variables

myCol = "The College of Information Technology CIT was founded in 2001. The mission of the CIT is to offer solid student centered programs. The CIT was designed so as to bring down the traditional walls that separate departments within a college. All CIT courses are developed and taught using the Blackboard course management system and the entire CIT campus is equipped with wireless internet access.";

}

public String mycol( String wordLen)

{

return wordLen.length();

}

/**

* An example of a method - replace this comment with your own

*

* @param y a sample parameter for a method

* @return the sum of x and y

*/

public boolean countWordsShorterThan(String var, int wordLen)

{

if (var.length < wordLen)

return myCol.length();

else

return false;

}

}

تم تعديل هذه المشاركة بواسطة كله مستخدم في 27 مايو 2009 في 21:40

#2

ارجو الرد بأسرع وقت

احتاج الاجابه قبل الساعه 11

ضروري...

:(

#3

:cry: :cry:

ردو بلييز ضروري

:

:

#4

يا أخي لو كنت تنتبه لدروسك لما وجدت مشكلا

وحتى السؤال لم تقرأه جيدا، وهذا يدل أنك لم تعط التمرين الوقت والإهتمام الكافِيَيْن

المطلوب

public int countWordsShorterThan(String var, int wordLen)

وما كتبته

public boolean countWordsShorterThan(String var, int wordLen)

على كل حال، هذا الحل


{
// instance variables - replace the example below with your own
String myCol;

/**
* Constructor for objects of class MyCollege
*/
public MyCollege()
{
// initialise instance variables
myCol = "The College of Information Technology CIT was founded in 2001. The mission of the CIT is to offer solid student centered programs. The CIT was designed so as to bring down the traditional walls that separate departments within a college. All CIT courses are developed and taught using the Blackboard course management system and the entire CIT campus is equipped with wireless internet access.";
}

/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public int countWordsShorterThan(String var, int wordLen)
{
String[] words = var.split(" ");
int nbWords = 0;
for (int i = 0; i < words.length; i++) {
if (words.length() < wordLen)
nbWords++;
}
return nbWords;
}
public static void main(String[] args) {
MyCollege m = new MyCollege();
int n = m.countWordsShorterThan(m.myCol, 5);
System.out.println(n);
}
}
 public class MyCollege

#5

شكراً لكـ اخي الكريم على المساعده

في الحقيقه حاولت الحل لكن المشكله لا استطيع فهم طريقة عمل البرنامج حتى الان

ولا كيفية كتابة الكود بشكل صحيح

احاول في حل التمارين

ولكن هناك مشكله في التأسيس

لقد حاولت الحل لكن لم اوفق في حله

-_-

شكرا جزيلاً اخي الكريم

^^

#6

هل الكود لا يعمل؟؟

على كل حال، كل ما أطلبه هو أن تقوم بمجهود. وأعتذر لأن ردي كان فيه بعض الحدة :wink:

#7

الكود يعمل والحمدلله

سأبذل جهدا اكبر في المره القادمه ان شاءالله

:happy:

#8

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته

مرحباً بكم في منتدى الفريق العربي للبرمجة

نود تنبيهك أن العنوان غير مناسب.

الرجاء اختيار عنوان مناسب أكثر في مواضيعك القادمة، وهذا بمثابة إشعار للأهمية.

وفي حال التكرار سيتعرض موضوعك للإغلاق والحذف!!!

قواعد المشاركة

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…