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

كود آله حاسبه بلغة الجافا

بدأه WGJ في 5 أبريل 2005 · 5 رد · 19,941 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

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

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

و شكراً

#2

ابحث في المنتدى موجود اكثر من كود فقط ابحث

لست متواجد بشكل يومي

#3

هذا الكو د يتنفذ بشكل صحيح بالتوفيق

//package graphics3;

import java.awt.*;

import java.lang.ArithmeticException;

import java.awt.event.*;

import javax.swing.*;

import java.io.*;

public class calculator extends JFrame {

private JButton bot0,bot1,bot2,bot3,bot4,bot5,bot6,bot7,bot8,bot9,mul,div,addb,sub,point,equl,cl

ear;

private JTextField result;

private int u=0,s=0,m=0;

public static double b=1,a=0,c=0;

public String shash="",sh="",one,tow;

public calculator()

{

super("calculator");

Container c=getContentPane();

c.setLayout(new GridLayout(5,5,0,0));

c.setBackground(new Color(666090999));

Container cb=getContentPane();//666090999

cb.setLayout(new FlowLayout());//686080999

result=new JTextField("0",16);result.setEditable(false);

result.setBackground(Color.white);

cb.add(result);

bot7=new JButton("7");

bot7.setBackground(Color.WHITE);

bot7.setForeground(Color.blue);

c.add(bot7);

bot8=new JButton("8");

bot8.setBackground(Color.WHITE);

bot8.setForeground(Color.blue);

c.add(bot8);

bot9=new JButton("9");

bot9.setBackground(Color.WHITE);

bot9.setForeground(Color.blue);

c.add(bot9);

div=new JButton("/");

div.setForeground(Color.RED);

div.setBackground(Color.WHITE);

c.add(div);

bot4=new JButton("4");

bot4.setBackground(Color.WHITE);

bot4.setForeground(Color.blue);

c.add(bot4);

bot5=new JButton("5");

bot5.setBackground(Color.WHITE);

bot5.setForeground(Color.blue);

c.add(bot5);

bot6=new JButton("6");

bot6.setBackground(Color.WHITE);

bot6.setForeground(Color.blue);

c.add(bot6);

mul=new JButton("*");

mul.setForeground(Color.RED);

mul.setBackground(Color.WHITE);

c.add(mul);

bot1=new JButton("1");

bot1.setBackground(Color.WHITE);

bot1.setForeground(Color.blue);

c.add(bot1);

bot2=new JButton("2");

bot2.setBackground(Color.WHITE);

bot2.setForeground(Color.blue);

c.add(bot2);

bot3=new JButton("3");

bot3.setBackground(Color.WHITE);

bot3.setForeground(Color.blue);

c.add(bot3);

sub=new JButton("-");

sub.setForeground(Color.RED);

sub.setBackground(Color.WHITE);

c.add(sub);

bot0=new JButton("0");

bot0.setBackground(Color.WHITE);

bot0.setForeground(Color.blue);

c.add(bot0);

point=new JButton(".");

point.setBackground(Color.WHITE);

point.setForeground(Color.blue);

c.add(point);

equl=new JButton("=");

equl.setForeground(Color.RED);

equl.setBackground(Color.WHITE);

c.add(equl);

addb=new JButton("+");

addb.setForeground(Color.RED);

addb.setBackground(Color.WHITE);

c.add(addb);

clear=new JButton(" C ");

clear.setBackground(Color.WHITE);

clear.setForeground(Color.blue);

c.add(clear);

//-------------------

clchandler clc=new clchandler();

bot0.addActionListener(clc);

bot1.addActionListener(clc);

bot2.addActionListener(clc);

bot3.addActionListener(clc);

bot4.addActionListener(clc);

bot5.addActionListener(clc);

bot6.addActionListener(clc);

bot7.addActionListener(clc);

bot8.addActionListener(clc);

bot9.addActionListener(clc);

div.addActionListener(clc);

mul.addActionListener(clc);

addb.addActionListener(clc);

point.addActionListener(clc);

equl.addActionListener(clc);

sub.addActionListener(clc);

clear.addActionListener(clc);

setSize(220,216);

setResizable(false);

show();

}

public static void main(String[] args) {

calculator calc = new calculator();

}

private class clchandler implements ActionListener {

char csc;

public void actionPerformed( ActionEvent e )

{

if(e.getSource()!=addb&&e.getSource()!=sub&&e.getSource()!=div&&e.getSource()!=mul&&e.getSource()!=equl&&e.getSource()!=clear)

{

shash+=e.getActionCommand();

sh+=e.getActionCommand();

result.setText(shash);

s=1;

u=0;

}

else

if(e.getSource()==clear){m=0;s=0;shash="";sh="";result.setText("0");}

else

if(e.getSource()==point){shash=".";sh=".";}

else

{

try{

if(s==0)

{

sh="0";

shash="0";

s=1;

}

if(m==0)

{

if(u==0)

{

sh=result.getText();

sh += e.getActionCommand();

csc = e.getActionCommand().charAt(0);

m = 1;

}

else

{

sh += e.getActionCommand();

csc = e.getActionCommand().charAt(0);

m = 1;

}

}

else

{

csc=e.getActionCommand().charAt(0);

sh+=csc;

if(testmark(csc)==true)

{

sh=""+calcu(sh)+""+e.getActionCommand();

}

else

{

sh=""+calcu(sh);

m=0;

u=1;

}

}

shash="";

}catch(ArithmeticException r){}

catch(RuntimeException w){}

}

}

double calcu(String math)

{

int i=0;

double a,b,c=0;

char csc1;

one="";tow="";

if(math.charAt(0)=='-'){i++;}

while(testmark1(math.charAt(i))==false)

{

one+=""+math.charAt(i);

i++;

}

a=Double.parseDouble(one);

if(math.charAt(0)=='-'){a=a*-1;}

while(i<math.length()&&testmark1(math.charAt(i))==true)

{

i++;

}

csc1=math.charAt(i-1);

while(i<math.length()&&testmark1(math.charAt(i))==false)

{

tow+=""+math.charAt(i);

i++;

}

b=Double.parseDouble(tow);

switch (csc1)

{

case '+':c=a+b;break;

case '-':c=a-b;break;

case '*':c=a*b;break;

case '/':c=a/b;break;

}

result.setText(""+c);

return c;

}

boolean testmark(char ts)

{

if(ts=='+'||ts=='-'||ts=='/'||ts=='*')

return true;

return false;

}

boolean testmark1(char ts)

{

if(ts=='+'||ts=='-'||ts=='/'||ts=='*'||ts=='=')

return true;

return false;

}

}

}

:lol:

1
#4

يا بني السؤال من سنة 2005

أفهم أنا ايه الي موديك هناك؟؟

:lol: :lol:

تحياتي

حزمة المحرك الإصدارة 0.8

أي أحد يجد أني ظلمته فليراسلني

وبإذن الله لو كان له حق سيأخذه

728x90.png

#5

السلام عليكم

انا جديده في المنتدى سجلت ابغى كود اله حاسبه مطوره يعني موجود فيها جاتا وجا وابغاه بلغة الجافا ممكن تساعدوني لوسمحتو

وبرضو ابغى اعملو انترفيس زي الاله حقت الجوال يقدر احد يفيدني ايش ممكن استخدم لغة وكيف لاني مبتدئه ؟؟

بس ياريت اما سي او جافا او فيجول بيسك

وتحياتي لكم ^_^

#6

اختى الكريمه

ابحثى فالمنتدى ستجدى اكواد كثيره تتكلم عن ذلك

لكن هنا فالمنتدى لا يتم وضع اكواد جاهزه

فلابد من تقديم الكود الخاص بك وعرض ما هى المشكله التى تواجههك

وان شاء الله ستجدى الكثيرين ممن يساعدك فى ذلك

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

وذلك حسب قواعد المشاركه فى المنتدى

بالتوفيق

Software Developer
Mahmoudkelany.com


 

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…