From 20f4c8af05deed5c10103979ac6686c7f193f9b8 Mon Sep 17 00:00:00 2001 From: Emanuels Zaurins Date: Tue, 5 Aug 2025 13:07:31 +0200 Subject: [PATCH 1/2] ex 2 completed --- .../java/com/booleanuk/core/Exercise.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 8125ead..f724059 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -8,39 +8,39 @@ public class Exercise extends ExerciseBase { // 1. Change the value of the member below to be the result of adding numOne and numTwo together - public int numOnePlusTwo = 0; + public int numOnePlusTwo = numOne + numTwo; // 2. Change the value of the member below to be the result of multiplying numThree by numTwo - public int numThreeTimesNumTwo = 0; + public int numThreeTimesNumTwo = numThree * numTwo; // 3. Change the value of the member below to be the result of dividing numThree by numOne - public int numThreeDividedByNumOne = 0; + public int numThreeDividedByNumOne = numThree /numOne; // 4. Change the value of the member below to be the result of subtracting numOne from numThree - public int numThreeMinusNumOne = 0; + public int numThreeMinusNumOne = numThree -numOne; // 5. Change the value of the member below to be the sum of numOne, numTwo and numThree - public int sum = 0; + public int sum = numOne + numTwo + numThree; // 6. Change the value of the member below to be the sum of numOne, numTwo and numThree divided by numOne - public int numBytes = 0; + public int numBytes = (numOne + numTwo + numThree ) /numOne; // 7. Create a public char member named lastLetter containing the last letter of the English alphabet - + public char lastLetter = 'Z'; // 8. Create a public float member named pi that contains the value of pi to two decimal places - + public float pi = 3.14f; // 9. Create a public double member named piD that contains the value of pi to 5 decimal places - + public double piD = 3.14159d; public String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; @@ -49,25 +49,26 @@ public class Exercise extends ExerciseBase { // 10. Create a public member named fullName that contains the value of firstName and lastName concatenated together with a space in between - + public String fullName = firstName + " " + lastName; // 11. Create a public char member named tenthLetter that contains the tenth letter in the alphabet member above. // If you need help, here's some documentation: https://www.w3schools.com/java/ref_string_charat.asp - + public char tenthLetter = alphabet.charAt(9); // 12. Create a public string member named lowerAlphabet that contains the value of the alphabet member in all lower case characters // If you need help, look through the available String methods to find a relevant one here: https://www.w3schools.com/java/java_ref_string.asp - + public String lowerAlphabet = alphabet.toLowerCase(); // 13. Create a public integer member named alphabetLength that contains the number of characters that exist in the alphabet member // Use the documentation linked above if you need help + public int alphabetLength = alphabet.length(); // 14. Create a public integer member named remainder that contains the remainder of dividing 15 by 8 - + public int remainder = 15%8; } From b37f05cd0576d739044799dacb7105069da3de02 Mon Sep 17 00:00:00 2001 From: Emanuels Zaurins Date: Tue, 5 Aug 2025 13:07:56 +0200 Subject: [PATCH 2/2] ex 2 completed --- src/main/java/com/booleanuk/core/Exercise.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index f724059..335bb8d 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -67,6 +67,7 @@ public class Exercise extends ExerciseBase { public int alphabetLength = alphabet.length(); + // 14. Create a public integer member named remainder that contains the remainder of dividing 15 by 8 public int remainder = 15%8;