-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtyping.java
More file actions
38 lines (35 loc) · 1.22 KB
/
Copy pathtyping.java
File metadata and controls
38 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//estou terminando o código
//this code is not ready yet
import java.util.Random;
import java.util.Scanner;
import java.lang.Thread;
public class helloworld {
public static void main(String[] args) throws InterruptedException {
Scanner sc = new Scanner(System.in);
Random random = new Random();
char randomChar;
System.out.println("digite a palavra");
String palavra = sc.nextLine();
String[] array = palavra.split("");
String formacao = "";
for (int i = 0; i < array.length; i++) {
if (i == array.length - 1) {
System.out.println(palavra);
} else{
if (array[i].charAt(0) == ' ') {
formacao += ' ';
} else {
do {
randomChar = (char) ('a' + Math.abs(random.nextInt()) % 26);
if (randomChar == array[i].charAt(0)) {
formacao += randomChar;
}
System.out.println(formacao + randomChar);
Thread.sleep(10);
} while (randomChar != array[i].charAt(0));
}
}
sc.close();
}
}
}