-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChallengeTwo.java
More file actions
29 lines (25 loc) · 941 Bytes
/
Copy pathChallengeTwo.java
File metadata and controls
29 lines (25 loc) · 941 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
public class ChallengeTwo {
public static double stringToDouble(String number) {
/**
* Return a double storing the value in the string number
* Arguments
* number - a string representing a double floating-point number
* Examples
* odds("3.14159") returns the double 3.14159
*/
// ====================================
// Do not change the code before this
// CODE1: Write code to store the number string in a double and return the double
double d = Double.parseDouble(number);
return d;
// ====================================
// Do not change the code after this
}
public static void main(String[] args) {
double theDouble = stringToDouble("3.14159");
double expected = 3.14159;
// Expected output is
// true
System.out.println(theDouble == expected);
}
}