1. Make a program that says “ouch” every time a key is pressed. You can use the speak() method below.
static void speak(String words) {
if (System.getProperty("os.name").contains("Windows")) {
String cmd = "PowerShell -Command \"Add-Type -AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('"
+ words + "');\"";
try {
Runtime.getRuntime().exec(cmd).waitFor();
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
Runtime.getRuntime().exec("say " + words).waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}