diff --git a/lesson_04/ljmcwilliams/README.md b/lesson_04/ljmcwilliams/README.md new file mode 100644 index 000000000..5ca25dc29 --- /dev/null +++ b/lesson_04/ljmcwilliams/README.md @@ -0,0 +1,59 @@ +In this lesson, I explored the differences between Java and JavaScript. Despite their similar names, these languages have distinct features. + +- ## Key Differences +- ### Document Preparation: + + - Java requires preparation before defining variables and functions. +JavaScript has more flexibility with variable definitions. + +- ### User Input: + + - In Java, I used the Scanner class to prompt the user for number input. +This required importing Java's Scanner class. +In JavaScript, there is no built-in Scanner class, so I used Node.js as a workaround. +With Node.js, I utilized process.stdin for input and process.stdout for output (similar to console.log). + +- ### Loop Control: + + - Both languages allow for loops to be exited early, but the methods differ: +In Java, using a break statement within the loop will terminate it. +In JavaScript, I opted for read.close(), which achieves a similar effect. + +- ### Variable Declaration: + + - Java requires explicit declaration of variable types. +JavaScript automatically assigns variable types. +- ## Loop Behavior +Both languages share similarities in loop functionality: + +- **For Loops**: + - Take three expressions. + +- **If Statements**: + - Accept a condition and can be nested. + +- **Java Example** +```java +for (int i = 2; i < userInput; i++) { + if ((userInput / i) == (int) (userInput / i)) { + System.out.println(userInput + " is not a prime number."); + isConditionMet = true; + break; + } + } if (!isConditionMet) { + System.out.println(userInput + " is a prime number."); + } +``` +- **JavaScript Example** +```javascript +for (let i = 2; i < answer; i++) { + if ((answer / i) == parseInt(answer / i)) { + console.log(answer + " is not a prime number."); + isConditionMet = true; + read.close(); + } + } if (!isConditionMet) { + console.log(answer + " is a prime number."); + read.close(); + } +``` \ No newline at end of file diff --git a/lesson_04/ljmcwilliams/findPrimeNum.java b/lesson_04/ljmcwilliams/findPrimeNum.java new file mode 100644 index 000000000..3b588aae5 --- /dev/null +++ b/lesson_04/ljmcwilliams/findPrimeNum.java @@ -0,0 +1,32 @@ +import java.util.Scanner; //This allows us to use the scanner to take in user input +public class findPrimeNum { + public static void main(String[] args) { + Scanner objScanner = new Scanner(System.in); //A scanner named 'objScanner' + boolean isConditionMet = false; + + /*if the condition is met, the print statement within the loop will be printed. + If not, the print statement after the loop will be printed*/ + + System.out.print("Please enter a whole number: "); //User input prompt + double userInput = objScanner.nextDouble(); //This reads an integer value from the user + + /*to determine a number's primality, we can check to see if the division + of that number by 2 to (1 - that number) results in any whole number quotients. + Once we do the division we can compare that number to (int) number to see if the + values are equal.*/ + + /*the program should end if A: the first whole number quotient is found, indicating that + * indicating a number is not prime or if B: no whole number quotients are found within the + * range indicating the number IS prime.*/ + + for (int i = 2; i < userInput; i++) { + if ((userInput / i) == (int) (userInput / i)) { + System.out.println(userInput + " is not a prime number."); + isConditionMet = true; + break; //this helps jump out of the loop once this first whole number quotient instace is found + } + } if (!isConditionMet) { + System.out.println(userInput + " is a prime number."); + } + } +} \ No newline at end of file diff --git a/lesson_04/ljmcwilliams/findPrimeNum.js b/lesson_04/ljmcwilliams/findPrimeNum.js new file mode 100644 index 000000000..3b78c3b49 --- /dev/null +++ b/lesson_04/ljmcwilliams/findPrimeNum.js @@ -0,0 +1,21 @@ +const readline = require('readline'); //"require()" imports the readline module which will process the user input +const read = readline.createInterface({ + input: process.stdin, //this acts as an input scanner + output: process.stdout //this works like a normal console.log combined with a user's input +}); +let isConditionMet = false; + +/* When looking at the Node.js docs, it states '.question()' displays the query (in this case the user prompt). +It waits for an input and uses it as the first argument in a callback function (here I am using a arrow function). */ +read.question("Enter a number: ", (answer) => { + for (let i = 2; i < answer; i++) { + if ((answer / i) == parseInt(answer / i)) { //similar to the "(int)" statement in java, parseInt converts doubles to ints + console.log(answer + " is not a prime number."); + isConditionMet = true; + read.close(); //this works similar to a break statement in java and ends the program + } + } if (!isConditionMet) { + console.log(answer + " is a prime number."); + read.close(); + } +}) \ No newline at end of file diff --git a/lesson_05/ljmcwilliams/README.md b/lesson_05/ljmcwilliams/README.md new file mode 100644 index 000000000..4c4821222 --- /dev/null +++ b/lesson_05/ljmcwilliams/README.md @@ -0,0 +1,84 @@ +## User Story 1: Offline Learning Mode for Language App +As a language learner,
I want an offline mode in the language learning app,
so I can continue learning without an internet connection. + +### Acceptance Criteria +
    +
  1. Access to Lessons: + +
  2. +
  3. Content Availability: + +
  4. +
  5. Sync Progress: + +
  6. +
+ +## User Story 2: Receive E-Statements for Bank Account +As a customer,
I want to receive e-statements for my bank account,
so I can reduce paper waste. + +### Acceptance Criteria +
    +
  1. Customer Information Validation: + +
  2. +
  3. E-statement Delivery + +
  4. +
  5. Notification Preferences Management: + +
  6. +
+ +## User Story 3: Keyboard Navigation for Faster Programming +As a software engineer,
I want to be able to navigate the IDE using keyboard shortcuts,
so that I can perform actions more quickly. + +### Acceptance Criteria +
    +
  1. Shortcut configuration:
  2. + +
  3. Common actions support:
  4. + +
  5. Shortcut discoverability:
  6. + +
\ No newline at end of file diff --git a/lesson_05/quiz/src/lesson5.ts b/lesson_05/quiz/src/lesson5.ts index 9ad62bd67..74ec75628 100644 --- a/lesson_05/quiz/src/lesson5.ts +++ b/lesson_05/quiz/src/lesson5.ts @@ -38,7 +38,7 @@ export class Lesson5 { [AnswerChoice.C, "To insert an image"], [AnswerChoice.D, "To create a paragraph"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -52,7 +52,7 @@ export class Lesson5 { [AnswerChoice.C, "alt"], [AnswerChoice.D, "href"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.C, ); } @@ -66,7 +66,7 @@ export class Lesson5 { [AnswerChoice.C, "
"], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -80,7 +80,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, "
"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -94,7 +94,7 @@ export class Lesson5 { [AnswerChoice.C, "Computer Style Sheets"], [AnswerChoice.D, "Cascading System Sheets"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -108,7 +108,7 @@ export class Lesson5 { [AnswerChoice.C, "text-color"], [AnswerChoice.D, "background-color"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -122,7 +122,7 @@ export class Lesson5 { [AnswerChoice.C, "/* this is a comment */"], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.C, ); } @@ -136,7 +136,7 @@ export class Lesson5 { [AnswerChoice.C, "text-size"], [AnswerChoice.D, "text-style"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -150,7 +150,7 @@ export class Lesson5 { [AnswerChoice.C, "inline-block"], [AnswerChoice.D, "none"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -164,7 +164,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.A, ); } } diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 13cb2ca05..7afa9a50e 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -2,10 +2,25 @@ export class ExpressionCalculator { /** Returns the calculation of ((a + b) * c) / d^e */ calculate(a: number, b: number, c: number, d: number, e: number): number { // Implement your code here to return the correct value. - return 0; + const sum = this.add(a, b); + const product = this.multiply(sum, c); + const exp = this.pow(d, e); + const quotient = this.divide(product, exp); + return quotient; } pow(base: number, exponent: number): number { return Math.pow(base, exponent); } + add(addendA: number, addendB: number): number { + return addendA + addendB; + } + divide(dividend: number, divisor: number): number { + return dividend / divisor; + } + multiply(factorA: number, factorB: number): number { + return factorA * factorB; + } } + +//divide(multiply(add(a, b), c), pow(d, e))