Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package senai;
- import java.text.DecimalFormat;
- import javax.swing.JOptionPane;
- public class Desafio08 {
- public static void main(String[] args) {
- StringBuffer mask = new StringBuffer();
- DecimalFormat df = new DecimalFormat("0000");
- int senha = Integer.parseInt(JOptionPane.showInputDialog("Digite uma senha númerica de 4 dígitos"));
- mask.append(df.format(senha));
- boolean correta = false;
- StringBuffer tentativa = new StringBuffer();
- //System.out.println(mask);
- JOptionPane.showMessageDialog(null, mask);
- while(correta != true) {
- if(tentativa.equals(mask)) {
- System.out.println("Senha correta");
- JOptionPane.showMessageDialog(null, "senha correta");
- correta = true;
- }else if(tentativa != mask) {
- for (int i = 0; i < 10000; i++) {
- tentativa.append(df.format(i));
- System.out.println(tentativa);
- tentativa.append("\n");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment