File tree 4 files changed +79
-0
lines changed
4 files changed +79
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java .io .IOException ;
2
+
3
+ public class FruitAvg {
4
+ public static void main (String [] args )
5
+ {
6
+ double numOranges = 50.0E-1 ;
7
+ double numApples = 1.0E1 ;
8
+ double avgFruit = 0.0 ;
9
+
10
+ avgFruit = (numOranges + numApples )/2.0 ;
11
+
12
+ System .out .println ("Calculate fruits" );
13
+ System .out .println ("Average of fruits: " + avgFruit );
14
+
15
+ System .out .println ("(Press ENTER to leave)" );
16
+
17
+ try
18
+ {
19
+ System .in .read ();
20
+ }
21
+ catch (IOException e )
22
+ {
23
+ return ;
24
+ }
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ import java .io .IOException ;
2
+
3
+ public class MatchStrings {
4
+
5
+ public static void main (String [] args ) {
6
+ String string1 = "Too many " ;
7
+ String string2 = "cooks" ;
8
+ String string3 = "Too many cooks" ;
9
+
10
+ string1 += string2 ;
11
+
12
+ System .out .println ("Test 1" );
13
+ System .out .println ("string3 is now: " + string3 );
14
+ System .out .println ("string1 is now: " + string1 );
15
+
16
+ if (string1 == string3 )
17
+ {
18
+ System .out .println ("string1 == string3 is true." +
19
+ " string1 and string3 point to the same string" );
20
+ }
21
+ else
22
+ {
23
+ System .out .println ("string1 == string3 is false." +
24
+ " string1 and string3 do not point to the same string" );
25
+ }
26
+
27
+ string3 = string1 ;
28
+
29
+ System .out .println ("\n \n Test 2" );
30
+ System .out .println ("string3 is now: " + string3 );
31
+ System .out .println ("string1 is now: " + string1 );
32
+
33
+ if (string1 == string3 )
34
+ {
35
+ System .out .println ("string1 == string3 is true." +
36
+ " string1 and string3 point to the same string" );
37
+ }
38
+ else
39
+ {
40
+ System .out .println ("string1 == string3 is false." +
41
+ " string1 and string3 do not point to the same string" );
42
+ }
43
+
44
+ try
45
+ {
46
+ System .in .read ();
47
+ }
48
+ catch (IOException e )
49
+ {
50
+ return ;
51
+ }
52
+ }
53
+ }
You can’t perform that action at this time.
0 commit comments