InstagramTwitterSnapChat


 
وصف

العودة   منتديات سكاو > الكليات الجامعية > منتدى كلية الحاسبات وتقنية المعلومات > المنتدى العام لكلية الحاسبات وتقنية المعلومات
   
   


المنتدى العام لكلية الحاسبات وتقنية المعلومات قسم خاص بالمواد العامة و الطلاب غير المتخصصين بكلية الحاسبات وتقنية المعلومات

[cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

المنتدى العام لكلية الحاسبات وتقنية المعلومات

 
 
أدوات الموضوع إبحث في الموضوع انواع عرض الموضوع
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 22-09-2010, 11:51 PM   #11

هوتميلكوم

جامعي

 
تاريخ التسجيل: Apr 2010
التخصص: computer science
نوع الدراسة: إنتظام
المستوى: الأول
الجنس: أنثى
المشاركات: 22
افتراضي رد: [cpcs 202 - برمجة 1] لديك سؤال , شيء غير مفهوم ,,, تفضل هنا , موضوع مفيد

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

أخي أحمد إن أمكن أتمنى ان تحل لي السؤال التالي بلغة الجافا وجزاك الله خيراً..

Credit card numbers follow certain pattern. A credit card number must be 16 digits, and must start with
• 4 for Visa cards
• 5 for Master cards
• 37 for American Express cards
• 6 for Discover cards
Suppose that you were asked to write down a Java program that validates the credit card number (if it is correct or not!). Here are the rules that determine the correctness of credit card number:
Suppose the credit card number = 4388576018402625
1) Double every second digit from right to left. If doubling of a digit results in a two-digit number, add up the two digits to get a single digit number:
2*2 = 4
2*2 = 4
4*2 = 8
1*2 = 2
6*2 = 12 (1 + 2) = 3
5*2 = 10 (1 + 0) = 1
8*2 = 16 (1 +6) = 7
4*2 = 8

2) Now add all single-digit number from step 1 (4+4+8+2+3+1+7+8 = 37)

3) Add all digits in the odd places from right to left in the card number:
5+6+0+8+0+7+8+3 = 37

4) Sum the results from step 2 and 3
37 + 37 = 74

5) If the result in step 4 is divisible by 10, then credit card is valid, else it is not valid.
74 is not divisible by 10, so it is not valid!
Write a java program to accept a credit card number from keyboard as long, and then prints on screen, if it is valid or not. You should use the following:
public static int[] fillArray(long) : this method fills the credit card number in an array
public static int getSum(int[]) :calculated the summation from step 1 and 2
Public static int getOddSum(int[]): calculates the summation from step 3
Public static boolean isValid(int, int): determines if valid or not according to step 5.

 

هوتميلكوم غير متواجد حالياً   رد مع اقتباس
 

 

أدوات الموضوع إبحث في الموضوع
إبحث في الموضوع:

البحث المتقدم
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

الانتقال السريع

 


الساعة الآن 02:30 PM


Powered by vBulletin® Version 3.8.9 Beta 3
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Ads Organizer 3.0.3 by Analytics - Distance Education

أن كل ما ينشر في المنتدى لا يمثل رأي الإدارة وانما يمثل رأي أصحابها

جميع الحقوق محفوظة لشبكة سكاو

2003-2025