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

سؤالين لوسمحتوا عاجل جدااااااااااااااااااااااا

مغلق
بدأه delphi team في 27 أبريل 2004 · 9 رد · 900 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم شباب

لقد مر علي أكثر من شهرين وانا أدرس هذه اللغة الغريبة نوعا ما

ولقد وجدت بعض الصعوبة في درستها وأريد بعض المساعدة أو بالأحرى أريد حل هذين السؤالين الغريبين؟؟

حاليا انا عما أدرس JAVA1.3.4

السؤال الأول

برنامج يقوم بإدخال عدد مؤلف من 4 خانات ومنثما يشفر العدد على الشكل التالي

لو افترضنا ان العدد المدخل هو 5793

يقوم بزيادة 7 إلى كل رقم يعني تصبح الأرقام السابقة على الترتيب

12 14 16 10

ثم يقوم البرنامج بفحص كل عدد إذا كان أكبر من العشرة أو لا اذا كان أكبر من عشرة يقوم بتقسيم العدد على 2 وتصبح الأرقام كالتالي

6 7 8 5

ثم وأخيرا يقوم بتبديل بين الأرقام على الشكل التالي

5 8 7 6

الأول مع الأخير والثاني مع الثالث

ثم يطبع البرنامج العدد قبل وبعد التشفير

بالله هذا مو سؤال تعجيزي!!!!!

أما السؤال الثاني

برنامج يقوم بحجز مقعد لمسافر في طائرة

وهو طائرة مؤلفة من 10 مقاعد ضمن قسمين الأول للمدخنين (رقم واحد) والقسم الثاني لغير المدخنين

والقسم الأول يحتوي على المقاعدة من 1 إلى 5 والقسم الثاني يحتوي على المقاعدة من 6 إلى 10

أولا يتم أدخال القسم المطلوب الحجز فيه ثم يتم التفتيش عن مقعد فارغ في هذا القسم وفي حال وجود مقعد فارغ يتم حجزه وإعطاء رقمه للمسافر وفي حال عدم وجود مقعد في القسم المطلوب يسأل المسافر عن إمكانية الحجز في القسم الثاني في حال الموافقة يتم البحث عن مقعد فارغ وفي حال وجوده يتم حجزه وإعطاء رقمه للمسافر

وفي حال عدم العثور على مقعد فارغ ايضا في الفسم الثاني تطبع عبارة انتظر الرحلة الثانية أيضا سوف تطبع نفس العبارة في حال عدم موافقة المسافر على الحجز في القسم الثاني ..

وانا بانتظار ردودكم الكريمة

عفوا على الإطالة ولكم الشكر مقدما

أخوكم

تم تعديل هذه المشاركة بواسطة delphi team في 27 أبريل 2004 في 01:16

When You Started With Delphi ...You Could Not Stop!

delphiteam2.jpg

alharmoodiGropu.com

#2

اف و الله شي يجنن راجه هذا الموضوع ربما تعتبر

/index.php?showtopic=40285

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

#3

شكرا أخوي رامي بس بعرف هذه الأشياء ولكن تساعدني على أيجاد الحل

اذا في حدا من الأخوة يستطيع حل السؤال الأول فقط اكون له من اشاكرين لأنة هو الأصعب

When You Started With Delphi ...You Could Not Stop!

delphiteam2.jpg

alharmoodiGropu.com

#4

عليكم السلام

أخ delphi team صراحة الموضوع ليس فيه كثير من الصعوبات..وإتما يحتاج بأن تعرف كيف تتعامل مع الدوال الموجودة في الكلاس String والكلاس StringBuffer..

بما أنه عاجل جداَََ..فهذا هو الكود.. إن شاء الله:

char [] one=new char[4];
    int [] two=new int[4];
    one=txtOne.getText().trim().toCharArray();
    for(int a=0;a<one.length;a++)
    {
      two[a]=Integer.parseInt(String.valueOf(one[a]))+Integer.parseInt(String.valueOf('7'));
    }

    for(int b=0;b<two.length;b++)
    {
      if (two >= 10) {
        two = two / 2;
      }
      else {
        two = two;
      }
    }
    //================
    StringBuffer a=new StringBuffer();
    for(int i=0;i<two.length;i++)
    {
      a.append(two);
    }
    txtBefore.setText(txtOne.getText());
    txtTwo.setText(a.reverse().toString());

لاحظ اني نسخت فقط الكود المطلوب ولم اتطرق الى تصميم الواجهة فهذا عليك الباقي..

اما بالنسبة الى السؤال الثاني فهو إنما تعاملك مع قاعدة البيانات من خلال الإستعلامات التي تؤذيها على الجداول الخاصة بلإستعلام..ويمكنك عمله اسهل عن طريق الإجراءات(Stored Procedures) الموجودة في قاعدة بيانات Sql Server إذا كنت تستخدمها..إذا لم تكن تستخدمها فعليك بلإستعلام..ومن تم تستخدم الدوال الموجود في الجافا لعملية الإستفادة من هذه النتائج..

يالتوفيق إن شاء الله..

بسام باصمد

techvisio.gif

اللهم انصر إخواننا المجاهدين في كل مكان..

#5

الله يعطيك الف عافية بس انا لس عما اشتغل على JAVA 1.3.4 يعني عني على الدوس:(

انا قصدت ردك على السؤال الثاني انا لسه حتى شكل المرئي للجافا ما بعرفو الا عنطريق البرامج الصغيرة

يسلمو كتير

تم تعديل هذه المشاركة بواسطة delphi team في 27 أبريل 2004 في 19:22

When You Started With Delphi ...You Could Not Stop!

delphiteam2.jpg

alharmoodiGropu.com

#6

about the first question :

we can find each digite by using int and divide by its 10'th value

exampe

5680

if we divide it by 1000

then teh result is 5

and you can then add 7

and see if it more than 10 amd divide it by 5

for the second digite

5680

first divide by 100

then find teh result of its mod ... % ... by 10 which will give you 6

i.e.

5680

divide 100

the result is 56

now ... 56 %10

the result is 6

and do teh same of the remain and you will get all the four digite..

....

......

the second question ... simply creat an array .... and do search on it ..

good like in your project

#7

طيب الله يعطيك العافية مشي حال الأول بس السؤال الثاني لسه....

انا عما أدرس جافا بس موGUI يعني على الدورسسسسسسسس

بدي حل السؤال الثاني على اساس مصفوفو من النوع BOOLEAN

ولكم جزيل الشكر

When You Started With Delphi ...You Could Not Stop!

delphiteam2.jpg

alharmoodiGropu.com

#8
import java.io.*;

public class Problem1{

//To Count the Number 5793 is 4 Number also 5,7,9,3

public static int HowMuch(int number)

{

int t = 0 ;

for(int i=0;i<number;i++)

{

int rest =number%10;

number=number/10;

t = 0 ;

}

return t;

}

public static void main(String [] args)throws IOException

{

int number;

BufferedReader din = new BufferedReader( new InputStreamReader(System.in));

System.out.println("Number : ");

number = Integer.parseInt(din.readLine());

for(int i=0;i<number;i++)

{

int rest = (number%10)+7;

if(rest >=10)

{

rest =rest/2;

}

else{rest=rest; }

number =number/10;

System.out.print(rest);

}

}

}

لست متواجد بشكل يومي

#9

teh answer for teh first question ...

in very long ... but simple method

import java.io.*;
import java.lang.*;



public class TheMain {
//variables
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String Numbers = new String();
  int Ntotal;
  int N[] = new int[4];

  public TheMain()
  {
    Numbers = null;
    Ntotal = 0;
    N[0] = N[1] = N[2] = N[3] = 0;

    System.out.print("\n Enter the Number:");
    readUserInput();
    stringToInt();
    addNumber(7);
    divideIfMoreThan10(2);
    swap();

    Numbers = " "+N[0]+N[1]+N[2]+N[3];
    System.out.print("\n the number After Decoded= "+Numbers);
  }// end constract

  // method to read the user input----------------------------------------------
  public void readUserInput()
  {
    try {
            Numbers = br.readLine();
         } catch (IOException ioe) {
            System.out.println("IO error trying to read your name!");
            System.exit(1);
         }
  }// end method readUserInput

  // method to change String to int---------------------------------------------
  public void stringToInt()
  {
    try{
         Ntotal= Integer.parseInt(Numbers);
         } catch(NumberFormatException e){
            System.out.print("Error wrong Formate");
            System.exit(1);
         }
    if(Ntotal > 10000)
      {
        System.out.print("the number is more than 4 digite...");
        System.exit(1);
      }
   else if(Ntotal < 1000)
      {
        System.out.print("the number is less than 4 digite...");
        System.exit(1);
      }
    else
       {
       for (int i = 0; i < N.length; i++)
            {
            try{
            N= Character.getNumericValue(Numbers.charAt(i));
               } catch(NumberFormatException e)
                 {
                 System.out.print("Error wrong Formate");
                 }
        }// end for
        }//end else
  }// end method stringToInt

  //method to add number to the numbers-----------------------------------------
  public void addNumber(int ADD)
  {
   for(int i = 0; i < N.length; i ++)
     {N+= ADD;    }
  }// end method addNumber

  // method to divide by 2 -----------------------------------------------------
  public void divideIfMoreThan10(int DIV)
  {
     for(int i = 0; i < N.length; i ++)
       {
         if(N > 10)
         {N/= DIV;}
       }
    }// end method

 //method to swap the numbers---------------------------------------------------
 public void swap()
 {
   int Temp;
   Temp = N[0];
   N[0] = N[1];
   N[1] = Temp;

   Temp = N[2];
   N[2] = N[3];
   N[3] = Temp;


 }

  public static void main(String[] args) {

    TheMain theMain1 = new TheMain();

  }//end the main method

}// end TheMain class

i hope it solve your problem

#10

The Answer for the second Question

import java.io.*;
import java.lang.*;




public class TheMain {
  int NumberOfSeets = 10;

   int Seet[] = new int[NumberOfSeets];
   int NumberOfSelection;
   int NSP = 0; // Non Smook Pointer
   int SP = (NumberOfSeets/2);  // Smook Pointer

   char YN;
   String UserSelection;
   int groupNumber;


   public TheMain() {
     while (isPlanFull())
     {selectGroup();}
   }

   // method to test if the pane is full or not----------------------------------
   public boolean isPlanFull()
   {
   if((NSP < NumberOfSeets/2) && (SP < NumberOfSeets ))
      {return true;}
     else return false;
   }

   //method to check the an empty seet-------------------------------------------
   public boolean isThereEmptySeet(int SeetGroup)
   {
     if(SeetGroup < NumberOfSeets/2) // Non Smooking Group
     {
       if ((SeetGroup+1) == (NumberOfSeets/2)) return false;//Non Smooking is full
       else
         {
           NSP ++;
           return true;
         }
     }// end non smooking part

     else
     {if ((SeetGroup+1) == NumberOfSeets ){return false;}
      else
      {
       SP++;
       return true;
      }
     }// end smooking part
   }// end method isThereEmptySeet

   //method to select the group--------------------------------------------------
   public void selectGroup()
   {
   System.out.print("\n which seet do you wont:\n\t1)Non Smooking.\n\t2)Smooking.\n\t\t:");
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   try {
          // readthe user input
          UserSelection = br.readLine();
        } catch (IOException ioe) {
           System.out.println("IO error trying to read your name!");
           System.exit(1);
        }
        try{
          groupNumber= Integer.parseInt(UserSelection);
        } catch(NumberFormatException e){
           System.out.print("Error group number");
           System.exit(1);
        }
   bookSeet();
   }//end method selectGroup

   //method to book the seet-----------------------------------------------------
   public void bookSeet()
   {
     int GroupSelection = 0;
     if(groupNumber != 1 && groupNumber !=2 ) //if wrong group number input
        {
          System.out.print("Error "+groupNumber+" not a valid group Numbner");
          System.exit(1);
        }
     if(groupNumber == 1){GroupSelection = NSP;}
     else{GroupSelection = SP;}

     if(isThereEmptySeet(GroupSelection))
     {System.out.print("\n Your Seet Number is:"+(++GroupSelection));}
     else{
       System.out.print("\nSorry, no seet is avelabel in this group.");
       System.out.print("\n\t Do you wont the other group? Y/N:");
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       try {
          // readthe user input
          UserSelection = br.readLine();
          YN = UserSelection.charAt(0);
        } catch (IOException ioe) {
           System.out.println("IO error trying to read your name!");
           System.exit(1);
        }
        if((YN == 'Y') ||(YN == 'y'))
           {
             groupNumber=(groupNumber == 1? 2 : 1);
             if(groupNumber == 1){GroupSelection = NSP;}
             else{GroupSelection = SP;}
             if(isThereEmptySeet(GroupSelection))
             {System.out.print("\n Your Seet Number is:"+(++GroupSelection));}
             else {System.out.print("\nWait for Next Flight");System.exit(1);}
           }

       else {System.out.print("\nWait for Next Flight,"); System.exit(1);}

     }
   }//end methodbookSeet

  public static void main(String[] args) {

    TheMain theMain1 = new TheMain();

  }//end the main method

}// end TheMain class

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

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

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

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

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

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