قمت بحل السؤال الثاني أما الثالث لم أفهمه فأرجوا من أي شخص أن يوم بحله مع العلم سأضع كود السؤال الثاني:
ملاحظة قمت بارفاق الصورة
String studentName="";
double mark1=0.0;
double mark3=0.0;
double mark2=0.0;
double Avarege=0.0;
String msgbox="";
double Msmu;
Scanner SC = new Scanner(System.in);
studentName =SC.next();
System.out.println("ُEnter Yor name:");
System.out.println("Enyer your first mark:");
mark1 = SC.nextDouble();
System.out.println("Enyer your third mark:");
System.out.println("Enyer your secound mark:");
mark2 = SC.nextDouble();
mark3 = SC.nextDouble();
System.out.println("Sum of your marks:"+Msmu);
Msmu =mark1+mark2+mark3;
msgbox = ("excellent with Honor's grade");
Avarege = Msmu/300*(100);
System.out.println("your avarage:"+Avarege);
if (Avarege==100){
}else if(Avarege >90&&Avarege<90){
msgbox = ("excellant");
}else if(Avarege >80&&Avarege<89){
msgbox = ("very good");
}else if(Avarege >50&&Avarege<59){
}else if(Avarege >70&&Avarege<79){
msgbox = ("good");
msgbox = ("Acceptable"); }else if(Avarege >90&&Avarege<69){
msgbox = ("pass");
}else {
}
msgbox = ("fail");
System.out.println(msgbox);
}
يرجى الدخول لحسابك أو تسجيل حساب لتستطيع إضافة تعليق
حساب جديد
دخول
التعليقات
مرحبا،
لدي ملاحظة: عليك الاهتمام بترتيب الشيفرة البرمجية و تنسيقها.
إن التبديل بين أماكن الشروط و أوامر الطباعة يعطي برنامجا خاطئ.
أصلحت الأخطاء و عدلت المطلوب..
أدخلنا عدد المواد ضمن المتحول NumOfMarks وحلقة بعدد المواد ندخلهم الواحدة تلو الأخرى و نجمعهم / استخدمنا متحول وحيد وهو كافِ)
بالنسبة لشروط العلامة الطريقة في الصورة خاطئة حيث لن تأخذ العلامات 60 - 70 - 80 ..
فهي لن تنتمي إللى أي مجال ..
تسلسل كتابة الشروط مع استخدام if else يمكنك من حذف الجزء الثاني من الشرط لأنه ليس ضروري
public static void main(String[] args) {
Scanner SC = new Scanner(System.in);
String studentName, msgbox;
double mark, Avarege, Msmu = 0.0;
int NumOfMarks;
System.out.println("Enter Yor name:");
studentName = SC.next();
System.out.println("Enter The Number Of Marks:");
NumOfMarks = SC.nextInt();
for (int i = 1; i <= NumOfMarks; i++) {
System.out.println("Enyer your " + i + " mark:");
mark = SC.nextDouble();
Msmu += mark;
}
System.out.println("Your name is:" + studentName);
System.out.println("Sum of your marks:" + Msmu);
Avarege = Msmu / (double) NumOfMarks;
System.out.println("your avarage:" + Avarege);
if (Avarege == 100) {
msgbox = ("excellent with Honor's grade");
} else if (Avarege >= 90 && Avarege < 100) {
msgbox = ("excellant");
} else if (Avarege >= 80 && Avarege < 90) {
msgbox = ("very good");
} else if (Avarege >= 70 && Avarege < 80) {
msgbox = ("good");
} else if (Avarege >= 60 && Avarege < 70) {
msgbox = ("Acceptable");
} else if (Avarege >= 50 && Avarege < 60) {
msgbox = ("pass");
} else {
msgbox = ("fail");
}
System.out.println(msgbox);
}