عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 16-02-2012, 10:42 AM   #6

asma'a

مشرفة مُتألقة سابقة

الصورة الرمزية asma'a

 
تاريخ التسجيل: Oct 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: CS ولله الحمد ^^..
نوع الدراسة: إنتظام
المستوى: متخرج
البلد: جــــدة
الجنس: أنثى
المشاركات: 1,514
افتراضي رد: بخصوص لاب البرمجة

أ/ سبايدر ..

هذا هوا السؤال ^^..

كود PHP:
Use a one-dimensional array to solve the following problemWrite an application that inputs five numberseachof which is between 10 and 100inclusive. As each number is readdisplay it only if it is not a duplicate of a numberalready readProvide for the “worst case,” in which all five numbers are different. Use the smallest possiblearray to solve this problemDisplay the complete set of unique values input after the user inputs each new value
وهذا حلوو بس موو كامل .. والمطلوب اننا نستبدل التعليقات بأكواد ^^..

كود PHP:
// Lab 1: Unique.java
// Reads in 5 unique numbers.
3 import java.util.Scanner;
4
public classUniqueTest
6
{
7    public static void mainString args[] )
8{
9    getNumbers();
11// end main
12
13
// gets 5 unique numbers from the user
14public void getNumbers()
15  {
16Scanner input = new ScannerSystem.in );
17
18
/* Create an array of five elements*/
19int count 0// number of uniques read
20int entered 0// number of entered numbers
21
22
while( entered numbers.length )
23{
24    System.out.print("Enter number: " );
25    /* Write code here to retrieve the input from the user */
26
27    
// validate the input
28    /* Write an if statement that validates the input */
29    {
30    // flags whether this number already exists
31        booleancontainsNumber false;
32
33        
// increment number of entered numbers
34        entered++;
35
36
/* Compare the user input to the unique numbers in the array using a for
37statement. If the number is unique, store new number */
38
39
/* add the user input to the array only if the number is not already
40in the array */
41if ( !containsNumber )
42{
43/* Write code to add the number to the array and increment
44unique items input */
45}// end if
46else
47System.out.printf("%d has already been entered\n",
48number );
49}// end if
50else
51System.out.println("number must be between 10 and 100" );
52
53
// print the list of unique values
54/* Write code to output the contents of the array */
55}// end while
56}// end method getNumbers
57}// end class UniqueTest 
وهذا الاوت بووووت
كود PHP:
Enter number11
11
Enter number
85
11 85
Enter number
26
11 85 26
Enter number
11
11 has already been entered
11 85 26
Enter number
41
11 85 26 41 
بالتوفيق ..

دمتـَ بخير ..

 

توقيع asma'a  

 

الحسد يجعل بعض الناس يلجؤوا الى طرق خبيثة وملتوية للتقليل من شأن ( الناجحين )
بسبب ضعف الشخصية و الإنهزامية لديهم

ودائما الحاسد يظل في المؤخرة ..

لـ/ ـلؤي نسيم || Loai Nassem ..


*.*.*.*.*.*

يقول الرب جل وعلا: " فَاسْتَجَابَ لَهُ رَبُّهُ فَصَرَفَ عَنْهُ كَيْدَهُنَّ إِنَّهُ هُوَ السَّمِيعُ الْعَلِيمُ " سورة يُوسف (34)

 

asma'a غير متواجد حالياً   رد مع اقتباس