Here's an example code in Java that converts user input into Braille points:
```java
import java.util.*;
public class BrailleConverter {
private static final Map brailleMap = new HashMap<>();
static {
brailleMap.put('a', "⠈⠁");
brailleMap.put('b', "⠈⠃");
brailleMap.put('c', "⠈⠉");
brailleMap.put('d', "⠈⠙");
// Add other mappings for Braille points here
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Digite o texto a ser convertido para Braille: ");
String input = scanner.nextLine().toLowerCase();
StringBuilder convertedText = new StringBuilder();
for (char c : input.toCharArray()) {
if (brailleMap.containsKey(c)) {
convertedText.append(brailleMap.get(c));
} else {
convertedText.append(c);
}
}
System.out.println("Texto em Braille: " + convertedText);
}
}
```
In this code, we use a `HashMap` called `brailleMap` to store the mappings between each character and its corresponding Braille points. You can add more mappings for the remaining characters if needed.
The program prompts the user to enter text to be converted into Braille. It converts each character to its Braille representation if available, and appends it to the `convertedText` string. If a character does not have a Braille representation, it is appended as is.
Finally, the converted Braille text is printed to the console.
0 Comentários