From 2111ea8e5816fe40040f28a07e56e288c6fe26fa Mon Sep 17 00:00:00 2001 From: Lowe Raivio Date: Tue, 7 Jan 2025 15:02:39 +0100 Subject: [PATCH 1/2] all test passes --- .../java/com/booleanuk/core/Exercise.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 8125ead..404a1e3 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -8,39 +8,40 @@ 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"; @@ -48,26 +49,28 @@ public class Exercise extends ExerciseBase { public String lastName = "Smith"; // 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 = String.format("%s %s",firstName, lastName); // note: alternative : public String fullName = firstName + " " + lastName; // ugly... // 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 2a0ba8b3770ca5921bc7e19c54b7ae01c9eabf18 Mon Sep 17 00:00:00 2001 From: Lowe Raivio Date: Tue, 7 Jan 2025 15:04:45 +0100 Subject: [PATCH 2/2] Sorry, now all test passes --- src/main/java/com/booleanuk/core/Exercise.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/booleanuk/core/Exercise.java b/src/main/java/com/booleanuk/core/Exercise.java index 404a1e3..9efd33d 100644 --- a/src/main/java/com/booleanuk/core/Exercise.java +++ b/src/main/java/com/booleanuk/core/Exercise.java @@ -32,7 +32,7 @@ public class Exercise extends ExerciseBase { // 7. Create a public char member named lastLetter containing the last letter of the English alphabet - public char lastLetter = 'z'; + public char lastLetter = 'Z';