أخواني..أخواتي.. إلى محبي البرمجة(جافا) لكل من لديه هوس في تقنية المعلومات ..ويحب عالم البرمجة.. أطرح عليكم مسابقة في برنامج الجافا وهما سؤالين وأتمنى أن اجد إجابة عليهما من الجميع في أقرب فرصة ممكنة.. السؤال الأول:. 1) Write a program to input values into an array and sort the array in descending order. Size of array is 10. Sorting is arranging a list in some order (ascending or descending). There are many sorting algorithms like bubble sorting, selection sorting, insertion sorting etc. An algorithm to sort a list in ascending order is given below: for( i = 0 to n-2) for(j=i+1 to n-1) if(array[i] > array[j]) swap the values of array[i] and array[j] * Array index starts from 0. * n is the size of the array *Swapping is interchanging the values of two variables. Search the internet for algorithm to swap the values of two variables. *This is bubble sort algorithm ــــــــــــــــــــــــــــــــــــــــــــــــــ ـــــــــــــــــــــــــــــ السؤال الثاني:- Write a program which will implement a class called NumberMagic. The class has one data member ‘n’ which is an integer. The member methods of the class are i. Default constructor :to initialize value of n to 10 ii. Specific constructor : to initialize the value of n. iii. setData : to set value of n. iv. printRial : to print the name for the denomination based on value of ‘n’ 1 - “Wahad Rial” 5 - “Khamsa Rial” 10 – “Ashara Rial” 50 – “Khamseen Rial” Otherwise - please check your value v. printFibo :to print ‘n’ terms of a Fibonacci series. 1,1,2,3,5,8,13,21… vi. printSeries :to print ‘n’ terms of a series where first term is ‘a’, and all other terms are obtained by adding ‘d’ to the previous term. vii. getSum :to calculate and return sum of first ‘n’ natural numbers. viii. isPrime :to return 1 if the number ‘n’ is prime, return 0 if the number ‘n’ is composite, and return -1 if the number ‘n’ is neither prime nor composite. Search the internet for algorithm on Fibonacci series and Prime number. بارك الله فيكم.....انتظر ردودكم على المسابقة...
مواقع النشر (المفضلة)