Win a copy of Spring Boot in Practice this week in the Spring forum!

Jd Wells

+ Follow
since Aug 19, 2013
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jd Wells

Thanks for the help Winston. I actually re-wrote most of the program. I got it working the way it was, but it really needed some work and I wasn't meeting other requirements for the project. Now that I have re-done it,
I cant seem to get my if statements which are comparing the dates to work. When I enter a date, It just prints out the last item in my arrayList, not matter what date I enter. I think I just need another set of eyes, cause I seem to be going in circles with it. Here is my driver program

All Im trying to get it to do first of all is to print out a sign if the date entered matches a date in the table. I get pisces every time.
7 years ago
I am writing a short program to find the zodiac of a given birth date. I am checking to see if a calendar object falls between to other objects to see if the date falls within a certain zodiac sign.
To accomplish this, I have the user enter a date, then that date is compared to dates taken from an array. The problem is sometimes the comparison doesnt seem to work work, giving the wrong zodiac. For example if I enter 03/28/1968, it finds Aries, as expected. However if I enter 03/20/1968, it returns Aries also, when it should return Pisces. Here is the sample code.

This is the class that creates the table used for the zodiac dates -

I cant seem to see why it returns the wrong zodiac.. maybe I just need a second set of eyes.. lol

7 years ago
Thanks everyone!
7 years ago
I am having a problem getting my head around the Date and SimpleDateFormat. I have tried several ways to get
get the date formatted in a the way I want, but I keep getting "Fri Apr 03 00:00:00 EST 1970" for my output.

My latest code is as follows:

Any help would be greatly appreciated..
7 years ago
Problem solved! Was getting extra stuff in the file that I wasnt seeing before, using one text editor. Tried a different editor and now I get 0 as I should and the file
is getting processed properly. Thanks everyone!
8 years ago
Darryl - sorry,, without the quotes.

Matthew - when I use nextInt(), I get this - java.util.InputMismatchException.

And it is a 0 and not an o.
8 years ago
I am having a problem trying to read in a string (its actually just 0) and converting it to an int. I keep getting : Exception in thread "main" java.lang.NumberFormatException: For input string: "0"

I tried using trim, in case there were white spaces, but that doesn't seem to work either. Here is a code snippet...

try {
Scanner whereIn = new Scanner(new FileReader("where.txt"));

where = Integer.parseInt(;


} catch (FileNotFoundException ex) {
Logger.getLogger(character.class.getName()).log(Level.SEVERE, null, ex);
The only thing in the file is "0".
8 years ago
Ah.. That cleared things up quite a bit! Thank you...
8 years ago
Im trying to catch a file not found exception so that my program can do something when it occurs, but I keep getting "FileNotFound exception is never thrown in body of corresponding try statement."
I am using a try catch block in the following piece of code to attempt this.

String[] goChar = new String[6];
public BQ() {

try {
Scanner charIn = new Scanner("character.txt");

int count = 0;

while (charIn.hasNext())
goChar[count] =;
count ++;

} catch(FileNotFoundException e) {

JOptionPane.showMessageDialog(null,"Welcome to Bodacious Quest, where questing\n "
+ "is the name of the game. To begin,\n we need to get some information from you,\n "
+ "the bodacious player. Please complete the\n following screens to set up your character." ,null, JOptionPane.INFORMATION_MESSAGE);



Any assistance would be greatly appreciated. Thanks!
8 years ago
I looked at the file and it looks like there is no space before the "35".. Any other suggestions? Im still scratching my head...
8 years ago
I keep getting a java.util.inputMismatchException while trying to open and read from a simple text file. I believe the exception is thrown because of a mismatch between what is in the file and what is being expected. The file contents are: 35 question A choicea choiceb choicec choiced . It looks like the error is being thrown when trying to read "35" from the file. It should be read into qnumber which is an int. The code im trying to use is as follows:

import java.util.*;

import javax.swing.JOptionPane;
public class tData {

private int key;
private int qNumber;
private String question;
private String answer;
private String choicea;
private String choiceb;
private String choicec;
private String choiced;
private String[] nquestion = new String[6];

public tData(int key){

public String[] sendQuestions(){
try {
Scanner inFile = new Scanner(new FileReader("trivia.txt"));
while (inFile.hasNext())
qNumber = inFile.nextInt();
question =;
answer =;
choicea =;
choiceb =;
choicec =;
choiced =;

if (key == qNumber)
JOptionPane.showMessageDialog(null,"Key and qnumber are" + key + qNumber ,null, JOptionPane.INFORMATION_MESSAGE);

} catch (FileNotFoundException e) {
// TODO Auto-generated catch block

return nquestion;

The line number referenced with the exception is pointing to this: qNumber = inFile.nextInt();
I know it is probably something very simple, but I am just not seeing it. Any help would be greatly appreciated... thanks!
8 years ago