Guest User

Untitled

a guest
Apr 27th, 2020
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package senai;
  2.  
  3. import java.text.DecimalFormat;
  4.  
  5. import javax.swing.JOptionPane;
  6.  
  7. public class Desafio08 {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. StringBuffer mask = new StringBuffer();
  12. DecimalFormat df = new DecimalFormat("0000");
  13. int senha = Integer.parseInt(JOptionPane.showInputDialog("Digite uma senha númerica de 4 dígitos"));
  14. mask.append(df.format(senha));
  15. boolean correta = false;
  16. StringBuffer tentativa = new StringBuffer();
  17.  
  18. //System.out.println(mask);
  19.  
  20.  
  21. JOptionPane.showMessageDialog(null, mask);
  22.  
  23. while(correta != true) {
  24.  
  25.  
  26. if(tentativa.equals(mask)) {
  27. System.out.println("Senha correta");
  28. JOptionPane.showMessageDialog(null, "senha correta");
  29. correta = true;
  30. }else if(tentativa != mask) {
  31. for (int i = 0; i < 10000; i++) {
  32. tentativa.append(df.format(i));
  33. System.out.println(tentativa);
  34. tentativa.append("\n");
  35. }
  36. }
  37.  
  38. }
  39.  
  40.  
  41. }
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment