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

[ تنبيه ] مساعدة في حل برنامج

بدأه omaryn في 30 أكتوبر 2010 · 11 رد · 961 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لو سمحتو اريد تصصيح لهدا البرنامج

One of the academic staff is trying to keep track of students’ information and their semester results in his class. Write a program to read the name, metric

number, and the semester average for ten students in this class using

one array to save the information for each individual student. Your program should allow the user to read the related information about each student and show the results.

import java.util.Scanner;

public class Assignment1 {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);

        String []a=new String [1];
        int [] b=new int[1];
        System.out.println("Enter Student name and metriv number" + a[1]+ b[1]  );
	    a[1]=scan.nextLine();}



	public static void Student (String []a){
	    for( int i=0;i>=10;i++){
        System.out.println("Enter"  + a);

		}
	}

		public static void MetricNumber (int b){
		for(int m=0; m>=10;m++){

		}
		}


	}

تم تعديل هذه المشاركة بواسطة .S.T.A.L.K.E.R في 30 أكتوبر 2010 في 21:13 — السبب: add code tag

#2

اتفضل اخى الكريم

 
/**
 *
 * @author Mahmoud Kelany
 */
import java.util.Scanner;

public class Assignment1 {

	static double[] degrees = new double[11];
	static String studentName;
	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {
    	System.out.println("Enter Student name : ");
    	studentName = scan.nextLine();
    	System.out.println("Enter metric number : ");
    	degrees[0] = scan.nextDouble();
    	getDegrees();
    	print();
	}

	public static void getDegrees() {
    	for (int i = 1; i < degrees.length; i++) {
        	System.out.println("Enter degree #" + (i));
        	degrees = scan.nextDouble();
    	}
	}

	public static void print() {
    	int sum = 0;
    	System.out.println("Student name : " + studentName + " , Student metric number : " + degrees[0]);
    	System.out.println("Student Degrees : ");
    	for (int i = 1; i < degrees.length; i++) {
        	System.out.print(degrees + " , ");
        	sum += degrees;
    	}
    	System.out.println("The average of " + sum + "  = " + (sum / 10));
	}
}

post-217802-084869800 1288462030_thumb.p

المرفقات
rrr.png

Software Developer
Mahmoudkelany.com


 

#3

*- يحظر استخدام اللهجة العامية

*- أو كتابة الأسئلة باللغة الإنجليزية

*- أو كتابة الكلمات الإنجليزية بالعربية

====

تم تعديل هذه المشاركة بواسطة .S.T.A.L.K.E.R في 30 أكتوبر 2010 في 21:14

#4

سلام ..

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

        static double[] degrees = new double[11];

مالفرق بين الـ Static Array والـ Array العادية ؟

#5
ToBeOrNotToBe كتب:

سلام ..

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

        static double[] degrees = new double[11];

مالفرق بين الـ Static Array والـ Array العادية ؟

اخى الكريم

انا اريد ان استخدم الـ array داخل داله static فلابد وانت يكون الـ array هى الاخرى static

انا استخدمتها داخل الـ main method فى هذا السطر

 degrees[0] = scan.nextDouble();

اذا ذكرت انها غير static

فانك لم تتمكن من رؤيه الdegress array

الا اذا استخدمت كلاس اخرى واستدعيت الدوال من خلالها

مثل هذه الطريقه

import java.util.Scanner;

/**
 *
 * @author Mahmoud Kelany
 */
public class Student {

    private double[] degrees = new double[11];
    private String studentName;
    private Scanner scan = new Scanner(System.in);

    public Student() {
        System.out.println("Enter Student name : ");
        studentName = scan.nextLine();
        System.out.println("Enter metric number : ");
        degrees[0] = scan.nextDouble();
        getDegrees();
        print();
    }

    public void getDegrees() {
        for (int i = 1; i < degrees.length; i++) {
            System.out.println("Enter degree #" + (i));
            degrees = scan.nextDouble();
        }
    }

    public void print() {
        int sum = 0;
        System.out.println("Student name : " + studentName + " , Student metric number : " + degrees[0]);
        System.out.println("Student Degrees : ");
        for (int i = 1; i < degrees.length; i++) {
            System.out.print(degrees + " , ");
            sum += degrees;
        }
        System.out.println("The average of " + sum + "  = " + (sum / 10));
    }
}

وهذه هى الكلاس التى تقوم بعمليه التشغيل

/**
 *
 * @author Mahmoud Kelany
 */
public class StudentTest {

    public static void main(String[] args) {
        Student s = new Student();
    }
}

ممكن تعمل دا الـ main

داخل الـ Student Class

زى كدا

import java.util.Scanner;

/**
 *
 * @author Mahmoud Kelany
 */
public class Student {

	private double[] degrees = new double[11];
	private String studentName;
	private Scanner scan = new Scanner(System.in);

	public Student() {
    	System.out.println("Enter Student name : ");
    	studentName = scan.nextLine();
    	System.out.println("Enter metric number : ");
    	degrees[0] = scan.nextDouble();
    	getDegrees();
    	print();
	}

	public void getDegrees() {
    	for (int i = 1; i < degrees.length; i++) {
        	System.out.println("Enter degree #" + (i));
        	degrees = scan.nextDouble();
    	}
	}

	public void print() {
    	int sum = 0;
    	System.out.println("Student name : " + studentName + " , Student metric number : " + degrees[0]);
    	System.out.println("Student Degrees : ");
    	for (int i = 1; i < degrees.length; i++) {
        	System.out.print(degrees + " , ");
        	sum += degrees;
    	}
    	System.out.println("The average of " + sum + "  = " + (sum / 10));
	}

	public static void main(String[] args) {
    	Student s = new Student();
	}
}

لكن انا بفضل يكون التقسيم بالمبدأ الصحيح :)

بالتوفيق :)

تم تعديل هذه المشاركة بواسطة Mahmoud Kelany في 30 أكتوبر 2010 في 21:29

Software Developer
Mahmoudkelany.com


 

#6
omaryn كتب:

لو سمحتو اريد تصصيح لهدا البرنامج

One of the academic staff is trying to keep track of students’ information and their semester results in his class. Write a program to read the name, metric

number, and the semester average for ten students in this class using

one array to save the information for each individual student. Your program should allow the user to read the related information about each student and show the results.

import java.util.Scanner;

public class Assignment1 {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);

        String []a=new String [1];
        int [] b=new int[1];
        System.out.println("Enter Student name and metriv number" + a[1]+ b[1]  );
	    a[1]=scan.nextLine();}



	public static void Student (String []a){
	    for( int i=0;i>=10;i++){
        System.out.println("Enter"  + a);

		}
	}

		public static void MetricNumber (int b){
		for(int m=0; m>=10;m++){

		}
		}


	}

احسنت وجزاك الله خير

#7

جزاكم الله خير على الحل ولكن البرنامج يطلب ادخال عشرة اسماء طلاب و لكل طالب له ميترك نبر(id) و الافرج) وثم يقوم بحساب الافرج لعشرة طلاب

#8
omaryn كتب:

جزاكم الله خير على الحل ولكن البرنامج يطلب ادخال عشرة اسماء طلاب و لكل طالب له ميترك نبر(id) و الافرج) وثم يقوم بحساب الافرج لعشرة طلاب

ايه المشكله اخى الكريم

الذى جعلك تدخل 10 درجات يجعلك تدخل 10 طلاب

حاول فيها بنفسك واعرض محاولاتك

اعتقد انها سهله

Software Developer
Mahmoudkelany.com


 

#9

السلام عليكم

هادي محاولة اخرى ولكن عندي خطا في average =Character.parseChar(JOptionPane.showInputDialog("Metric number"+i));

import javax.swing.JOptionPane;

public class Assignment {

/**

* @param args

*/

public static void main(String[] args) {

String []name = new String[10];

int [] id =new int[10];

char []average=new char[10];

for(int i=0;i<10;i++){

name=JOptionPane.showInputDialog("Name"+ i);

id=Integer.parseInt(JOptionPane.showInputDialog("Metric number"+i));

average =Character.parseChar(JOptionPane.showInputDialog("Metric number"+i));

}

for(int i=0;i<10;i++){

System.out.println("Student name "+ name + " metric number "+ id +" averge "+ average );

}

}

}

#10
average = Character.parseChar(JOptionPane.showInputDialog("Metric number" + i));

ايه Character.parseChar

مش موجود اساسا الموضوع دا

مفيش حاجه parseChar

صحح الكود وجرب تانى

Software Developer
Mahmoudkelany.com


 

#11

بصراحة ما اعرف الكود الصح وادا تعرف الكود الصح خبرني ادا تعرف

#12

صحح الكود اخى الكريم

ازاى ما بتعرف

لو فهمت اللى انا وضعته هتلاقى نفسك بتصحح الكود وبتعمل الكود الجديد

Software Developer
Mahmoudkelany.com


 

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