forked from League-Archive/IntroToJavaWorkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStephenHawking.java
More file actions
38 lines (30 loc) · 751 Bytes
/
StephenHawking.java
File metadata and controls
38 lines (30 loc) · 751 Bytes
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
import java.io.IOException;
import javax.swing.JOptionPane;
public class StephenHawking
{
// 1. make a main method and put steps 2, 3 & 4 inside it
public static void main(String[] args)
{
// 4. repeat steps 2 and 3 a lot of times
for (int i = 0; i < 99; i++)
{
// 2. ask the user for a sentence
String sent1 = JOptionPane.showInputDialog("Please enter a sentence");
// 3. call the speak method below and send it the sentence
speak(sent1);
}
}
/* Don’t change this…. */
static void speak(String words)
{
try
{
Runtime.getRuntime().exec("say " + words).waitFor();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
// Copyright Wintriss Technical Schools 2014