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

لماذا برامج لا يعمل

مغلق
بدأه alqabtan في 16 أكتوبر 2006 · 3 رد · 650 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

لماذا برامج لا يعمل

import javax.swing.JOptionPane;
public class Testput{
public static void main (String augs[]){
String n1,n2;
int num1,num2;
int sum;
n1=JOptionPane.showInputDialog ("enter the fist number");
n2=JOptionPane.showInputDialog ("enter the second number");
num1=Integer.parseInt (n1);
num2=Integer.parseInt (n2);
sum=n1 + n2;
JOptionPane.showMessgeDialog(null,"the sum="+sum,"results",JOptionPane,Plain_MESSAG);
System.exit(0);
}
}
#2

أخي العزيز حاول أن تكتب عنوان يدل على جوهر الموضوع

والخطأ هنا أنك لاتستطيع جمع n1 & n2 وهن من نوع String في متغير sum من نوع integer

انتبه ياأخي وابحث في المنتدى ، بارك الله فيك

#3

الخطا هنا

JOptionPane.showMessgeDialog(null,"the sum="+sum,"results",JOptionPane,Plain_MESSAG);

و هذا الكود بعد التعديل

import javax.swing.JOptionPane;
public class Testput{
	public static void main (String augs[]){
		String n1,n2;
		int num1,num2;
		int sum;
		n1=JOptionPane.showInputDialog ("enter the fist number");
		n2=JOptionPane.showInputDialog ("enter the second number");
		num1=Integer.parseInt (n1);
		num2=Integer.parseInt (n2);
		sum=num1 + num2;
		JOptionPane.showMessageDialog(null,"the sum="+sum,"results",JOptionPane.PLAIN_MESSAGE);
		System.exit(0);
	}
}
#4

شكرك :lol:

هذا الموضوع مغلق.

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