jason candelora

Greenhorn
+ Follow
since Sep 25, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by jason candelora

My example was terrible...after putting a bit more thought into it, this example would be better:
int someInt = 100;
for (int a = 0; a < someInt; a++)
{
String testString + someInt = "YUP";
}
So you would get 100 Strings such as testString1, testString2...testString100
Hope this makes it a bit more clear!
Thanks!
Jason
20 years ago
Hello!
In order to make my programs run with less code I would like to know if I can name objects with a String..I did it when I was into Visual Basic...something like this:
String testName = "testName"
int testName = 14
Is this possible at all???
Thanks,
Jason
20 years ago
Thanks for all of the help!! I will sooon have this one completed!
20 years ago
Hello,
I have an array that contains Points that are found on an X-Y axes. I am trying to sort these Points by their closeness to one another. In theory, I need to take the first point in my array, add it to the new array. Then take the second point in my array and insert it into the second place in the new array..heres where the fun starts...I then take the third point of my first array and check to see how far it is from the each of the 2 points in my new array, then it gets inserted into the new array directly after the point to which it is closest. Then we go to the fourth point and compare its distance from each of the 3 points in my new sorted array and insert it after the point that it is closest and so on until I run out of points...I am completely lost on this one...I am not looking for someone to feed me a ton of code that I can just plug in and go, I would like for someone to just point me in the right direction so I can at least get started...
Thanks for your time!!
Jason
20 years ago
Thanks a lot..it was the problem using a variable that was not instantiated..
Jason
20 years ago
java.lang.NullPointerException
at shapeDriver.main(shapeDriver.java:13)
Exception in thread "main"
20 years ago
Thanks, I appreciate the help!
20 years ago
ok...here is what I would do...

Let me know how this works for you!!
20 years ago
Here is my code...I was hoping I could get another pair of eyes to scan it and see what I might be doing wrong...All of my organisms die after the first cycle!

Any help would be appreciated!!!
Jason Candelora
20 years ago
Can someone help me to see why the variable result is valued at 88 and not 10?
import javax.swing.*;
import java.text.*;
import java.util.StringTokenizer;
public class romanNumeral
{
public static void main(String[] args)

{
int I = 1;

int V = 5;

int X = 10;

int L = 50;

int C = 100;

int D = 500;

int M = 1000;
String input = "X";

int i = input.length();

int b = 0;

int result = 0;

while (i > 0)

{

char character = input.charAt(b);

result = character;
i = i - 1;

b = b + 1;

}//end while

JOptionPane.showMessageDialog(null,

"Your converted string is " + result,

"The Results",

JOptionPane.INFORMATION_MESSAGE);

}//end method

}//end class
Thanks again!!!
20 years ago
Thanks for the help!
I ended up using a combination of both of our solutions to solve the problem...I really appreciate the insight!
Jason
20 years ago
Hi,
I want to take a string such as "Hello" and convert that to a string that looks like this: "h + e + l + l + o" . This is the loop that I am using to try to accomplish this feat:
import javax.swing.*;
import java.text.*;
import java.util.StringTokenizer;
public class romanNumeral
//Naming the class and declaring it to be public
{//begin class
public static void main(String[] args)

{//begin method
String input = "hello";

StringTokenizer tokenizer = new StringTokenizer (input);

int stringLength = input.length();

String word = " ";

String digit;

while (tokenizer.hasMoreTokens())

{//begin while

digit = tokenizer.nextToken();

if (stringLength == 1)

{//begin if

word = word + " " + digit;

}//end if

else

{//begin else

word = word + digit + " + " + stringLength;

}//end else

stringLength = stringLength - 1;

}//end while

JOptionPane.showMessageDialog(null,

"Your converted string is " + word,

"The Results",

JOptionPane.INFORMATION_MESSAGE);

}//end method

}//end class
This code returns "hello +".
I know that this is because the delimiter is not set right but I am not sure how to tell it to set each character as its own token as opposed to each word.
Please help!
Jason
20 years ago
I am not sure what you mean..I just pasted the code in from JGrasp and tried to make it more readable for you...
I also figured out that I needed to declare my variable outside of the main method to use them in more than that one method, it seems to work ok now...
thanks for the help
Jason
20 years ago
Hi,
I am not sure what is wrong with the following code, and was hoping that someone would shed some light on why I am getting the following errors when I try to compile.
newGame.java:55: cannot resolve symbol
symbol : variable number
location: class newGame
else if (test > number)
^
newGame.java:63: cannot resolve symbol
symbol : variable number
location: class newGame
else if (test < number)
^
2 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
PLEASE HELP!! (here is the code)
import javax.swing.*;
import java.text.*;
import java.util.Random;
public class newGame
{
public static void main(String[] args)
{
Random generator = new Random();
int number = generator.nextInt(1000);
String userInput = JOptionPane.showInputDialog("Give me a number between 0 and 1000");
int stringLength = userInput.length();
int guess = Integer.parseInt(userInput);
int checkedGuess = errorCheck(guess);
}
public static int errorCheck(int test)
{
if (test > 1000)
{
return 0;
}
else if (test > number)
{
return 1;
}
else if (test < number)
{
return 2;
}
else
return 3;
}
}
20 years ago
Thanks very much for all of your replys!
I will try some of this code later....
Jason
20 years ago