Java Memory Game  July 6, 2015, 11:11 pm 
In an assignment, I created a simple memory game. Memory Game. Also, I have a question. Which is better to use to close the program? System.exit(0)? Or dispose() to destroy the window, which already terminates the program on close? 

0 Comments 
Java GUI Calculator  July 2, 2015, 11:36 pm 
Here is a code for a calculator using GUI and event driven programming. One annoying problem is that the numbered buttons call the action method twice. Suggestions to improve the program is much appreciated. EDIT: An error found. Putting 0s in front of numbers might manipulate the calculation a bit. import java.awt.BorderLayout; 

3 Comments 
Finding the biggest object  June 27, 2015, 11:45 am 
I've been asked to write a method which is public static Object max(Object[] a). It should return the highest Object in an Object array using compareTo method. However, with this method's parameter, since Object doesn't have compareTo method, I'm supposed to put several if statements to determine if the object is an instanceof Account, or Employee, or other classes that use compareTo:
So I changed the function to this:
Which works fine, and I think it's similar to java.util.Arrays.max(anArray). But I heard that it's not a very good idea to do that. Is it healthy to do this? 

3 Comments 
Dealing with regex in Java  June 21, 2015, 4:41 pm 
I'm supposed to write a method that acts like java.lang.String.split, except that this new method returns a String array including the delimeters. For example: split("Java#HTML#Cpp", "#") would return "Java", "#", "HTML", "#" and "Cpp" in an array. I already done the hard part, which returns the array correctly. However, I don't how to make it work with regular expressions, such as: split("Java#HTML$Cpp%Python", "[#$%]"). It should return: "Java", "#", "HTML", "$", "Cpp", "%", "Python". Any ideas? Here is my code BTW:


5 Comments 
An algorithm for this  June 8, 2015, 9:44 am 
So I want the output to be this: ____5 (four spaces) ___45 (three spaces) __345 (and so on...) _2345 12345 Using without more than 2 loops. Doesn't matter any language, but C or Java works. 

5 Comments 
Variables in recursive functions  May 1, 2015, 8:09 am 
Yesterday, in my C programming lab, I was solving problems with recursions, the hardest part was that some of them required using variables inside recursive functions for better solutions. I tried to avoid declaring variables inside them as that would harm the memory, so I ended up declaring global variables, which ended in a mess. Here is an example of my functions:void arrayRecursion (int x[], int length) { The number "10" in the above code is the size of the array I declared later in the main function. I could use a constant value of 10 in SIZE, but a better way is to put another integer variable in the function to store length value like the comment I wrote, but this will make it change its value to the new length, and it will keep declaring integer type variable. int length = 6; This messy function is supposed to check if a string is a palindrom string. length's value is the length of the character array "LeooeL", same issue as the first code (putting the length as a variable). z (didn't bother to pick a name for it) should be used to indicate whenever it should stop checking, but I didn't finish the function, so I put a comment for each statement concerning it, as it's the not the issue here. Notice where I declared the variables, not favorable. 

7 Comments 
Can anyone explain this to me?  April 13, 2015, 12:25 pm 
EDIT: Nevermind, I misunderstood it at first. I thought that when I add "6", it would add to array[5] (or the sixth element of the array). Problem solved. This is for an assignment. I'm not asking for the solution, but I'm a bit confused:
It seems to me that the example is wrong, shouldn't element 7 become 6? And what if the 100th element (99) is shifted to the right? They didn't say anything about the limits. 

0 Comments 
Solving equations with e ^ x and x  April 1, 2015, 7:10 am 
Today, in my Calc II exam, I've came across the question of finding the derivative of an inverse function when x = 2. The function was as I remember: f(x) = e ^ 2x + 4x + 1 I didn't know how to solve for x algebraically after I substituted f(x) with 2 (or using ln or exp functions). So I put automatically x = 0 as it will satisfy the equation and then I proceeded. Luckily, it was a multiple choice question, so the method of solving isn't important. How do I solve this? 

7 Comments 
[SOLVED] Why is the output negative?  March 10, 2015, 9:59 am 
This code is supposed to calculate e to the power x. It works fine at lower numbers, but then at x = 3.6, the output starts to decrease as x goes up. What's wrong? C language. EDIT: The problem was that "factorial" function was an int, so at high values, it won't work.


9 Comments 
Minor in mathematics  February 25, 2015, 1:27 pm 
I'm majoring in computer science (first year), and I'm thinking of taking minor in math. The reason is because of its connection to computer science (since it's a subfield of math), and I like it a lot. The question is, are these a good pair? For CS degrees, math courses include Calculus I and II, Discrete Mathematics, Statistics, Linear Algebra and Numerical Methods. As for the mathematics minor, it includes Calculus III, Foundations of Mathematics, Normal Differential Equations, Mathematical Analysis I, Abstract Algebra I and other math courses in the choice of the student. I feel getting a minor in math is a waste of time. It's because where I live, computer scientists and engineers usually end up in programming jobs, or maintaining computers. So it's very likely that I won't work in the "theoretical" part of computer science, and I "assume" that math is applied more on the theoretical part than programming (or software engineering). Shall I forget it and pursue other minors, or am I being ignorant about how good it is to study such pair? 

2 Comments 