Guest User

Untitled

a guest
Jun 23rd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
  2. String n1,x1;
  3. int n,x,anz2=0,anz3=0,anz5=0,anzSonst=0;
  4. n1=tfN.getText();
  5. x1=tfX.getText();
  6. n=Integer.parseInt(n1);
  7. x=Integer.parseInt(x1);
  8.  
  9. for(int i=1; i<=n; i++)
  10. {
  11. switch(n%x)
  12. {
  13. case 2: anz2++;
  14. break;
  15. case 3: anz3++;
  16. break;
  17. case 5: anz5++;
  18. break;
  19. default: anzSonst++;
  20. }
  21. }
  22.  
  23. lbDurch2.setText(""+anz2);
  24. lbDurch3.setText(""+anz3);
  25. lbDurch5.setText(""+anz5);
  26. lbDurchsonst.setText(""+anzSonst);
  27. }
Add Comment
Please, Sign In to add comment