diff --git a/.idea/misc.xml b/.idea/misc.xml index d15472f..03f397c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/com/example/practice/CompoundAssignment.java b/src/com/example/practice/CompoundAssignment.java index f5bbb15..6f2c477 100644 --- a/src/com/example/practice/CompoundAssignment.java +++ b/src/com/example/practice/CompoundAssignment.java @@ -18,17 +18,16 @@ public static void main(String[] args) { the final result should be a variable that holds the original value of 1 */ - - - - - - - - - - - - + int num = 1; + num += 3; + System.out.println(num); + num *= 4; + System.out.println(num); + num -= 8; + System.out.println(num); + num /= 2; + System.out.println(num); + num %= 3; + System.out.println(num); } } diff --git a/src/com/example/practice/IncAndDec.java b/src/com/example/practice/IncAndDec.java index ba53284..8992ec0 100644 --- a/src/com/example/practice/IncAndDec.java +++ b/src/com/example/practice/IncAndDec.java @@ -16,16 +16,13 @@ public static void main(String[] args) { 4. Then repeat step 3 with the decrement operator (make sure to adjust the string output appropriately) - - */ - - - - - - - + int num = 10; + System.out.println("Initial value: " + num); // 10 + num++; + System.out.println("Value after increment: " + num); // 11 + num--; + System.out.println("Value after decrement: " + num); // 10 /* Now, using System.out.println(), print the value of your variable as you increment it @@ -33,7 +30,7 @@ public static void main(String[] args) { or if the returned value is not yet incremented */ - + System.out.println(num++); // Not yet incremented } diff --git a/src/com/example/practice/MathOps.java b/src/com/example/practice/MathOps.java index f317a2d..a33f041 100644 --- a/src/com/example/practice/MathOps.java +++ b/src/com/example/practice/MathOps.java @@ -14,17 +14,12 @@ public static void main(String[] args) { print out the values resulting from performing each of the five basic math operations on them (+, -, *, /, %) */ - - - - - - - - - - - - + int num1 = 10; + int num2 = 2; + System.out.println(num1 + num2); // 12 + System.out.println(num1 - num2); // 8 + System.out.println(num1 * num2); // 20 + System.out.println(num1 / num2); // 5 + System.out.println(num1 % num2); // 0 } } diff --git a/src/com/example/practice/Sout.java b/src/com/example/practice/Sout.java index fb3263b..f245b63 100644 --- a/src/com/example/practice/Sout.java +++ b/src/com/example/practice/Sout.java @@ -14,27 +14,24 @@ public static void main(String[] args) { System.out.println("Hello, world!"); // declare and define a variable of each of the 8 primitive data types in Java // (byte, short, int, long, float, double, boolean, char) - - - - - - - - + byte b = 100; + short s = 10000; + int i = 100000; + long creditCardNumber = 1234_5678_9012_3456L; + float pi = 3.14_15F; + double d = 123.4; + boolean boo = true; + char c = 'A'; // use System.out.println() to display the values of each variable to the system - - - - - - - - - - - + System.out.println(b); // 100 + System.out.println(s); // 10000 + System.out.println(i); // 100000 + System.out.println(creditCardNumber); // 1234_5678_9012_3456L + System.out.println(pi); // 3.14_15F + System.out.println(d); // 123.4 + System.out.println(boo); // true + System.out.println(c); // A } }