Avezbayeva Ozoda


Download 19.38 Kb.
Sana24.01.2023
Hajmi19.38 Kb.
#1116029
Bog'liq
Calculator02


// Avezbayeva Ozoda;

String s="",hisob="";


long son;
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
s=s+evt.getActionCommand();
text1.setText(s);
} //raqmlar kodi;

private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {


if(!s.equals("")){
switch(hisob){
case"":son= Long.parseLong(s);break;
case"+":son= (son + Long.parseLong(s));break;
case"-":son= (son - Long.parseLong(s));break;
case"*":son= (son * Long.parseLong(s));break;
case"/":son= (son / Long.parseLong(s));break;
case"x^n":son= (long) (Math.pow(son, Long.parseLong(s)));break;
}
s="";
text1.setText(String.valueOf(son));
}
hisob=evt.getActionCommand();
if(hisob.equals("C")){
text1.setText("");
s="";
hisob="";

}
} //Matematik amallar kodi;

private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {
int q=Integer.parseInt(text1.getText());
int massiv[]=new int[q];
int i=0,f=0;
while(q>0){
i=q%2;
q=q/2;
massiv[f]=i;
f++;
}
String w="";
while(f>0){
w+=(massiv[f-1]);
f--;
}
text1.setText(String.valueOf(w));
} // 2lik sanoq sistemasiga o’tish kodi

private void jButton20ActionPerformed(java.awt.event.ActionEvent evt) {


int q=Integer.parseInt(text1.getText());
int massiv[]=new int[q];
int i=0,f=0;
while(q>0){
i=q%8;
q=q/8;
massiv[f]=i;
f++;
}
String w="";
while(f>0){
w+=(massiv[f-1]);
f--;
}
text1.setText(String.valueOf(w));
} // 8lik sanoq sistemasiga o’tish kodi

private void jButton17ActionPerformed(java.awt.event.ActionEvent evt) {


int q=Integer.parseInt(text1.getText());
int massiv[]=new int[q];
int i=0,f=0;
while(q>0){
i=q%10;
q=q/10;
massiv[f]=i;
f++;
}
String w="";
while(f>0){
w+=(massiv[f-1]);
f--;
}
text1.setText(String.valueOf(w));
} // 10 lik sanoq sistemasiga o’tish kodi

private void jButton25ActionPerformed(java.awt.event.ActionEvent evt) {


double x=Double.parseDouble(text1.getText());
text1.setText(String.valueOf(Math.sin(x)));
} // sin(x) kodi;

private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {


double x=Double.parseDouble(text1.getText());
text1.setText(String.valueOf(Math.cos(x)));
} // cos(x) kodi;

private void jButton24ActionPerformed(java.awt.event.ActionEvent evt) {


double x=Double.parseDouble(text1.getText());
text1.setText(String.valueOf(Math.tan(x)));
} // tg(x) kodi;

private void jButton23ActionPerformed(java.awt.event.ActionEvent evt) {


double x=Double.parseDouble(text1.getText());
text1.setText(String.valueOf(1/(Math.tan(x))));
} // ctg(x) kodi;

private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {


double x=Integer.parseInt(text1.getText());
text1.setText(String.valueOf(Math.log10(x)));
} // logarif kodi;
Download 19.38 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling