عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 12-01-2012, 01:02 AM   #436

deathpain

devkemo

الصورة الرمزية deathpain

 
تاريخ التسجيل: Dec 2010
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: Computer Science
نوع الدراسة: إنتظام
المستوى: الثامن
البلد: جــــدة
الجنس: ذكر
المشاركات: 770
افتراضي رد: Cpcs 202 شروحات وحلول وواجبات الجافا

سؤال الفاينل:
Write a program that asks the user to enter Students names followed by their scores and then outputs the following ( Assume Maximum students number is 30 ):
a. Class Average
b. Print Students names who got scores below than the average
c. Print the highest score and print names of students who got the highest score

الحل:
كود PHP:
package finalexam;
import java.util.*;

public class 
FinalExam {

    public static 
void main(String[] args) {
    
String[] Names = new String[30];
    
double[] Scores = new double[30];
    
double Sum=0,Average=0,Max=Scores[0];
    
    
// Entering Values to arrays and calculate average
    
for (int i=0;i<30;i++)
        {
    
System.out.println("Enter Student ("+(i+1)+") Name: "); 
    
Names[i]=new Scanner(System.in).nextLine();
    
System.out.println("Enter Student ("+(i+1)+") Score: "); 
    
Scores[i]=new Scanner(System.in).nextDouble();
    
Sum+=Scores[i];
    if (
Scores[i]>Max)
       
Max=Scores[i];
        }
    
Average=Sum/30;
    
System.out.println("The Average of scores is: "+Average);
    
    
// Printing Names of students who has scores less than the average
    
for (int j=0;j<30;j++)
        {
    if (
Scores[j]<Average)
    
System.out.println(Names[j]+" Has a score less than the average");
        }
    
    
// Printing the highest score and the names of students who got the highest scores
    
System.out.println("The Highest Score is: "+Max);
    
System.out.println("The Students who got the highest score: ");
    for (
int z=0;z<30;z++)
        {
    if (
Scores[z]==Max)
    
System.out.println(Names[z]);
        }
    } 
// End of main method
// End of Class 
بالتوفيق للجميع

 

توقيع deathpain  

 



في حال وجود أي استفسار أو سؤال حول الجافا CPCS202 الرجاء كتابة استفسارك مباشرة في موضوعي هنا:

تطبيق - معدلي الجامعي - التطبيق الأسهل لحساب المعدل الجامعي
http://skaau.com/vb/showthread.php?t=745520

 

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