In the Mass Academy Computer Science course, students work on learning programming patterns in the Java programming language. Students who have demonstrated proficiency in the Java programming language pursue an Independent Computer Science Project (ICSP) throughout the year. Later in the year, students work on an Apps for Good project, in which they learn mobile development basics. Throughout the year, students maintain their personal websites.
My ICSP is an online database for Mass Academy to track and handle Alumni events, find judges for school science fairs, and find mentors for students' various projects. This site allows the administration of our school to handle student/alumni data in a centralized location. It also helps students connect to mentors and judges so that they can have better projects in their other classes and they can get the assistance they need.
Technologies I'm Using:
import java.util.*;
import java.util.stream.*;
public class PalindromicNumber
{
public static void main(String[] args)
{
int result = largestPalindrome(3);
System.out.println("Result: " + result);
}
// Find the largest palindrome multiple of n-digit numbers
public static int largestPalindrome(int digits)
{
int result = Intstream.range(1, Math.pow(10, digits - 1))
.flatMap(a -> Intstream.range(1, Math.pow(10, digits - 1))
.map(b -> a * b)) // Multiples of n-digit numbers
.filter(n -> isPalindrome(n)) // Filter for palindromes
.reduce(0, (a, b) -> (a > b)? a : b); // Reduce for maximum
return result;
}
// Checks if number is palindromic
public static boolean isPalindrome(int number)
{
String numAsString = Integer.toString(number);
// Reverse number as a string
String reversed = new StringBuilder()
.append(numAsString)
.reverse()
.toString();
// If number is equal to reversed, it is a palindrome
return numAsString.equals(reversed);
}
}
This is an example of Java code I wrote for this class. This finds the largest palindromic multiple of n digit numbers in a functional style. Using modern Java features helps make my code more elegant and concise. Though this example code is in Java, I largely use C, Javascript, or Python for my personal projects.
In this code, the isPalindrome(...) method, which determines if a number is palindromic by comparing its string representation to its reversed string representation, is used to filter through multiples of n-digit numbers in the largestPalindrome(...) method.