Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"name": "Java 17 Dev Container",
"image": "mcr.microsoft.com/devcontainers/java:0-17",
"name": "Java 21 Dev Container",
"image": "mcr.microsoft.com/devcontainers/java:21",
"customizations": {
"vscode": {
"extensions": [
"vscjava.vscode-java-pack",
"redhat.java"
]
"settings": {
"java.jdt.ls.java.home": "/usr/lib/jvm/msopenjdk-current",
"java.configuration.runtimes": [
{
"name": "JavaSE-21",
"path": "/usr/lib/jvm/msopenjdk-current"
}
]
}
}
},
"forwardPorts": [],
"postCreateCommand": "./.devcontainer/setup.sh"
}
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y maven",
"remoteUser": "vscode"
}
5 changes: 0 additions & 5 deletions .devcontainer/setup.sh

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Compiled class file
*.class

# Target Directory
target

# Log file
*.log

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Java Fundamentals Challenges

Open this repo in GitHub Codespaces:
[![Open in Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/FRC-7525/Java-Basics-Training-Assignment-2025)

## How students should work
1. Fork this repository (or "Use this template" if the repo is set as a template).
2. Open your fork in Codespaces (use the button above).
3. Create a branch for your solution: `git checkout -b username-ch1`
4. Implement methods / files in `src/main/java` and run tests with: `mvn test`
5. Push your branch and open a Pull Request back to the upstream `main` branch.

## Ignore this:
- Autograder: GitHub Actions runs `mvn test` on push and pull request.
DUE: Next meeting
Lmk if you have questions or can't complete it on time.

## STEPS:
1. Fork this repository
2. Open your fork in Codespaces.
3. Create a branch for your solution: `git checkout -b [SOME_BRANCH_NAME]`
4. Complete FundamentalsPractice and then PasswordChecker
4. Run tests with: `mvn test`
5. Stage changes, commit, and push branch.


75 changes: 42 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.classroom</groupId>
<artifactId>java-fundamentals-challenges</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.jupiter.version>5.9.3</junit.jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- surefire for running tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<useModulePath>false</useModulePath>
</configuration>
</plugin>
</plugins>
</build>
http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>java-basics</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.jupiter.version>5.10.0</junit.jupiter.version>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<release>21</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</build>
</project>
130 changes: 115 additions & 15 deletions src/main/java/challenges/FundamentalsPractice.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,125 @@

public class FundamentalsPractice {

// Ex: helper used by unit tests (students implement)
public static int sum(int[] arr) {
int s = 0;
for (int v : arr) s += v;
return s;
// Example: sum of two integers
public static int sum(int a, int b) { // The values in parentheses are set for you. Ex: Here a and b are assigned to integers and can be used in code
int total = a + b; // Your code goes here
return total; // To submit the answer, return it like this.
}

// Another example: average of doubles
public static double average(double[] arr) {
if (arr.length == 0) return 0.0;
double s = 0;
for (double v : arr) s += v;
return s / arr.length;
/**
* fizzbuzz - You are given an array of ints.
* Print "Fizz" for multiples of 3,
* "Buzz" for multiples of 5,
* and "FizzBuzz" for multiples of both 3 and 5.
* For other numbers, print the number itself.
* RETURN an array (NOT ARRAYLIST) that contains the number of times ["Fizz", "Buzz", "FizzBuzz"] were printed.
* Ex: Given [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15], you would RETURN: [3, 2, 1]
*/
public static int[] fizzbuzz(int[] arr) {
return null;
}

// main stays interactive for manual testing (optional)
/**
* reverseString - Given a String, return the reverse of the string.
* Ex: "hello" -> "olleh"
* Hint: You can convert an arary of characters back to a string like this:
* char[] charArray = {'h', 'e', 'l', 'l', 'o'};
* String str = new String(charArray); // str is "hello"
* Hint: You can convert a string to an array of characters like this:
* String str = "hello";
* char[] charArray = str.toCharArray(); // charArray is ['h', 'e', 'l', 'l', 'o']
*/
public static String reverseString(String input) {
// Your code goes here
return null;
}

/**
* maxInArray - Given an array of integers, return the largest value.
* Ex: [1, 5, 3, 9, 2] -> 9
*/
public static int maxInArray(int[] arr) {
// Your code goes here
return 0;
}

public static boolean stringsAreSame(String a, String b) {
// If strings are equal, return true. Else, return false
// Hint: use .equals() to compare strings not ==
// Do not care about capitals HI is equal to hi look up how to do.
return null;
}

/**
* countVowels - Given a string, return the number of vowels (a, e, i, o, u) in the string.
* Ex: "banana" -> 3
* Hint:
* - strings can be accessed like this: variable.charAt(0) returns the first character
*/
public static int countVowels(String input) {
// Your code goes here
return 0;
}

/**
* isPrime - Given an integer, return true if it is a prime number, false otherwise.
* Ex: 7 -> true, 8 -> false
* Hint: to check if n is prime, divide it by all integers from 2 to sqrt(n).
*/
public static boolean isPrime(int n) {
// Your code goes here
return false;
}

/**
* factorial - Given a non-negative integer n, return n! (n factorial).
* Ex: 5 -> 120
* Hint: n! = n * (n-1) * (n-2) * ... * 1, and 0! = 1
* don't use recursion.
* THIS ONE IS HARD
*/
public static long factorial(int n) {
// Your code goes here
return 0L;
}



// Use for Manual Testing
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("This is a starter file. Implement methods for unit tests.");
in.close();
System.out.println("================ RUNNING CODE ================");
// sum
int a = 3;
int b = 5;
System.out.println("sum(" + a + ", " + b + ") = " + sum(a, b)); // Expected: 8

// fizzbuzz
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 35, 36};
System.out.println("fizzbuzz(arr) = " + Arrays.toString(fizzbuzz(arr))); // Expected: [5, 4, 3]

// reverseString
String str = "hello";
System.out.println("reverseString('" + str + "') = '" + reverseString(str) + "'"); // Expected: 'olleh'

// maxInArray
int[] nums = {1, 5, 3, 9, 2};
System.out.println("maxInArray([1,5,3,9,2]) = " + maxInArray(nums)); // Expected: 9

// countVowels
String word = "banana";
System.out.println("countVowels('banana') = " + countVowels(word)); // Expected: 3

// isPrime
int primeTest = 7;
int notPrimeTest = 8;
System.out.println("isPrime(7) = " + isPrime(primeTest)); // Expected: true
System.out.println("isPrime(8) = " + isPrime(notPrimeTest)); // Expected: false

// factorial
int factTest = 5;
System.out.println("factorial(5) = " + factorial(factTest)); // Expected: 120

System.out.println("=============== DONE RUNNING ===============");
}
}
56 changes: 56 additions & 0 deletions src/main/java/challenges/PasswordChecker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import java.util.Scanner;

/*
* 🎯 Goal
*
* Create a program that:
* - Takes a password as input.
* - Checks:
* - Length ≥ 8
* - Contains uppercase, lowercase, number, and symbol
* - Outputs a strength rating:
* - “Weak”, “Moderate”, or “Strong”
* - “Weak” if length < 8 or missing 2+ types
* - “Moderate” if length ≥ 8 and missing 1 type
* - “Strong” if length ≥ 8 and has all 4 types
*
*
* 💡 Hints
* - Loop through each character with: for (char c : password.toCharArray()).
* - Use Character.isUpperCase(), Character.isLowerCase(), and Character.isDigit().
* - Symbol = not upper/lower/digit.
*/


public class PasswordStrengthChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// TODO: Prompt the user to enter a password and read it from input
// String password = scanner.nextLine();

// Call the method to check password strength
// String strength = checkPasswordStrength(password);

// TODO: Output the strength rating
// System.out.println(strength);

scanner.close();
}

/**
* Checks the strength of the given password.
* Returns "Weak", "Moderate", or "Strong".
*
* @param password The password to check
* @return The strength rating
*/
public static String checkPasswordStrength(String password) {
// TODO: Implement the logic to check password strength
// - Check length
// - Check for uppercase, lowercase, digit, and symbol
// - Return the appropriate rating

return ""; // Placeholder
}
}
Loading
Loading