File tree 3 files changed +105
-0
lines changed
3 files changed +105
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Sonny Li
2
+ // CMP 167: Programming Methods I
3
+
4
+ public class FlipCoin {
5
+
6
+ public static void main (String [] args ) {
7
+
8
+ if (Math .random () < 0.5 )
9
+ {
10
+ System .out .println ("Heads" );
11
+ }
12
+ else
13
+ {
14
+ System .out .println ("Tails" );
15
+ }
16
+
17
+ }
18
+
19
+ }
Original file line number Diff line number Diff line change
1
+ // Sonny Li
2
+ // CMP 167: Programming Methods I
3
+
4
+ import java .util .Scanner ;
5
+
6
+ public class SpaceBoxer {
7
+
8
+ public static void main (String [] args ) {
9
+
10
+ Scanner in = new Scanner (System .in );
11
+
12
+ double weight ;
13
+ int x ;
14
+
15
+ System .out .print ("Please enter your current earth weight: " );
16
+ weight = in .nextDouble ();
17
+
18
+ System .out .println ("\n I have information for the following planets:" );
19
+ System .out .println (" 1. Venus 2. Mars 3. Jupiter" );
20
+ System .out .println (" 4. Saturn 5. Uranus 6. Neptune\n " );
21
+
22
+ System .out .print ("Which planet are you visiting? " );
23
+ x = in .nextInt ();
24
+
25
+ if (x == 1 )
26
+ {
27
+ weight = weight * 0.78 ;
28
+ }
29
+ else if (x == 2 )
30
+ {
31
+ weight = weight * 0.39 ;
32
+ }
33
+ else if (x == 3 )
34
+ {
35
+ weight = weight * 2.65 ;
36
+ }
37
+ else if (x == 4 )
38
+ {
39
+ weight = weight * 1.17 ;
40
+ }
41
+ else if (x == 5 )
42
+ {
43
+ weight = weight * 1.05 ;
44
+ }
45
+ else if (x == 6 )
46
+ {
47
+ weight = weight * 1.23 ;
48
+ }
49
+
50
+ System .out .printf ("\n You weight would be %.2f pounds on that planet.\n " , weight );
51
+
52
+ }
53
+
54
+ }
Original file line number Diff line number Diff line change
1
+ // Sonny Li
2
+ // CMP 167: Programming Methods I
3
+
4
+ import java .util .Scanner ;
5
+
6
+ public class pH {
7
+
8
+ public static void main (String [] args ) {
9
+
10
+ Scanner in = new Scanner (System .in );
11
+
12
+ double ph ;
13
+
14
+ System .out .print ("Enter pH level (0-14): " );
15
+ ph = in .nextDouble ();
16
+
17
+ if (ph > 7 )
18
+ {
19
+ System .out .println ("Basic" );
20
+ }
21
+ else if (ph < 7 )
22
+ {
23
+ System .out .println ("Acidic" );
24
+ }
25
+ else
26
+ {
27
+ System .out .println ("~Neutral~" );
28
+ }
29
+
30
+ }
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments