what did you do that you managed to get a negative result?
you'll always get a positive result. sure, it's possible that you get a result which is below zero, and since your result is an integer (and because of that doesn't contain decimal points) it will be rounded to zero, but a negative result?

either your original number was negative, or the number by which you were dividing it was negative, otherwise, JeffGrigg is right:
32/10 = 3, not -3

Since it is too late for you to turn this in for the assignment...

package now;

import javax.swing.JOptionPane;

public class Rabbit {

	public static void main(String[] args) {
		int enter = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter number here:"));
		String result = toWords(enter);
		JOptionPane.showMessageDialog(null, result);
	}

	static String toWords(int enter) {
		int libo = enter / 1000;
		int dalawalibo = enter % 1000;
		int tatlolibo = libo * 1000;

		int daan = dalawalibo / 100;
		int dalawadaan = dalawalibo % 100;
		int tatlodaan = daan * 100;

		int tenna = dalawadaan / 10;
		int tenne = tenna * 10;
		int tenni = dalawadaan % 10;

		String ten = "";
		String teen = "";

		if (tenne == 10) {
			if (tenni == 9) {
				teen = "Nineteen";
			} else if (tenni == 8) {
				teen = "Eighteen";
			} else if (tenni == 7) {
				teen = "Seventeen";
			} else if (tenni == 6) {
				teen = "Sixteen";
			} else if (tenni == 5) {
				teen = "Fifteen";
			} else if (tenni == 4) {
				teen = "Fourteen";
			} else if (tenni == 3) {
				teen = "Thirteen";
			} else if (tenni == 2) {
				teen = "Twelve";
			} else if (tenni == 1) {
				teen = "eleven";
			} else if (tenni == 0) {
				teen = "ten";
			}
		} else {
			if (tenne == 90) {
				ten = "Ninety";
			} else if (tenne == 80) {
				ten = "Eighty";
			} else if (tenne == 70) {
				ten = "Seventy";
			} else if (tenne == 60) {
				ten = "Sixty";
			} else if (tenne == 50) {
				ten = "Fifty";
			} else if (tenne == 40) {
				ten = "Fourty";
			} else if (tenne == 30) {
				ten = "Thirty";
			} else if (tenne == 20) {
				ten = "Twenty";
//			} else if (tenne == 10) {
//				ten = "Ten";
			}

			if (tenni == 9) {
				teen = "Nine";
			} else if (tenni == 8) {
				teen = "Eight";
			} else if (tenni == 7) {
				teen = "Seven";
			} else if (tenni == 6) {
				teen = "Six";
			} else if (tenni == 5) {
				teen = "Five";
			} else if (tenni == 4) {
				teen = "Four";
			} else if (tenni == 3) {
				teen = "Three";
			} else if (tenni == 2) {
				teen = "Two";
			} else if (tenni == 1) {
				teen = "One";
			}
		}

		String hundred = "";

		if (tatlodaan == 900) {
			hundred = "Nine Hundred";
		} else if (tatlodaan == 800) {
			hundred = "Eight Hundred";
		} else if (tatlodaan == 700) {
			hundred = "Seven hundred";
		} else if (tatlodaan == 600) {
			hundred = "Six Hundred";
		} else if (tatlodaan == 500) {
			hundred = "Five Hundred";
		} else if (tatlodaan == 400) {
			hundred = "Four Hundred";
		} else if (tatlodaan == 300) {
			hundred = "Three Hundred";
		} else if (tatlodaan == 200) {
			hundred = "Two Hundred";
		} else if (tatlodaan == 100) {
			hundred = "One Hundred";
		}

		String thousand = "";
		if (tatlolibo == 10000) {
			thousand = "Ten Thousand";
		} else if (tatlolibo == 9000) {
			thousand = "Nine Thousand";
		} else if (tatlolibo == 8000) {
			thousand = "Eight Thousand";
		} else if (tatlolibo == 7000) {
			thousand = "Seven Thousand";
		} else if (tatlolibo == 6000) {
			thousand = "Six Thousand";
		} else if (tatlolibo == 5000) {
			thousand = "Five Thousand";
		} else if (tatlolibo == 4000) {
			thousand = "Four Thousand";
		} else if (tatlolibo == 3000) {
			thousand = "Three Thousand";
		} else if (tatlolibo == 2000) {
			thousand = "Two Thousand";
		} else if (tatlolibo == 1000) {
			thousand = "One Thousand";
		}

		String result = thousand + " " + hundred + " " + ten + " " + teen;
		return result;
	}
}

Since it is too late for you to turn this in for the assignment...

package now;

import javax.swing.JOptionPane;

public class Rabbit {

	public static void main(String[] args) {
		int enter = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter number here:"));
		String result = toWords(enter);
		JOptionPane.showMessageDialog(null, result);
	}

	static String toWords(int enter) {
		int libo = enter / 1000;
		int dalawalibo = enter % 1000;
		int tatlolibo = libo * 1000;

		int daan = dalawalibo / 100;
		int dalawadaan = dalawalibo % 100;
		int tatlodaan = daan * 100;

		int tenna = dalawadaan / 10;
		int tenne = tenna * 10;
		int tenni = dalawadaan % 10;

		String ten = "";
		String teen = "";

		if (tenne == 10) {
			if (tenni == 9) {
				teen = "Nineteen";
			} else if (tenni == 8) {
				teen = "Eighteen";
			} else if (tenni == 7) {
				teen = "Seventeen";
			} else if (tenni == 6) {
				teen = "Sixteen";
			} else if (tenni == 5) {
				teen = "Fifteen";
			} else if (tenni == 4) {
				teen = "Fourteen";
			} else if (tenni == 3) {
				teen = "Thirteen";
			} else if (tenni == 2) {
				teen = "Twelve";
			} else if (tenni == 1) {
				teen = "eleven";
			} else if (tenni == 0) {
				teen = "ten";
			}
		} else {
			if (tenne == 90) {
				ten = "Ninety";
			} else if (tenne == 80) {
				ten = "Eighty";
			} else if (tenne == 70) {
				ten = "Seventy";
			} else if (tenne == 60) {
				ten = "Sixty";
			} else if (tenne == 50) {
				ten = "Fifty";
			} else if (tenne == 40) {
				ten = "Fourty";
			} else if (tenne == 30) {
				ten = "Thirty";
			} else if (tenne == 20) {
				ten = "Twenty";
//			} else if (tenne == 10) {
//				ten = "Ten";
			}

			if (tenni == 9) {
				teen = "Nine";
			} else if (tenni == 8) {
				teen = "Eight";
			} else if (tenni == 7) {
				teen = "Seven";
			} else if (tenni == 6) {
				teen = "Six";
			} else if (tenni == 5) {
				teen = "Five";
			} else if (tenni == 4) {
				teen = "Four";
			} else if (tenni == 3) {
				teen = "Three";
			} else if (tenni == 2) {
				teen = "Two";
			} else if (tenni == 1) {
				teen = "One";
			}
		}

		String hundred = "";

		if (tatlodaan == 900) {
			hundred = "Nine Hundred";
		} else if (tatlodaan == 800) {
			hundred = "Eight Hundred";
		} else if (tatlodaan == 700) {
			hundred = "Seven hundred";
		} else if (tatlodaan == 600) {
			hundred = "Six Hundred";
		} else if (tatlodaan == 500) {
			hundred = "Five Hundred";
		} else if (tatlodaan == 400) {
			hundred = "Four Hundred";
		} else if (tatlodaan == 300) {
			hundred = "Three Hundred";
		} else if (tatlodaan == 200) {
			hundred = "Two Hundred";
		} else if (tatlodaan == 100) {
			hundred = "One Hundred";
		}

		String thousand = "";
		if (tatlolibo == 10000) {
			thousand = "Ten Thousand";
		} else if (tatlolibo == 9000) {
			thousand = "Nine Thousand";
		} else if (tatlolibo == 8000) {
			thousand = "Eight Thousand";
		} else if (tatlolibo == 7000) {
			thousand = "Seven Thousand";
		} else if (tatlolibo == 6000) {
			thousand = "Six Thousand";
		} else if (tatlolibo == 5000) {
			thousand = "Five Thousand";
		} else if (tatlolibo == 4000) {
			thousand = "Four Thousand";
		} else if (tatlolibo == 3000) {
			thousand = "Three Thousand";
		} else if (tatlolibo == 2000) {
			thousand = "Two Thousand";
		} else if (tatlolibo == 1000) {
			thousand = "One Thousand";
		}

		String result = thousand + " " + hundred + " " + ten + " " + teen;
		return result;
	}
}

yes i know i wont be able to pass it.. but either way i still want to figure out the logic, and how did it work, now i know my mistake.. :) thank you :)

Since it is too late for you to turn this in for the assignment...

goddamn that's some ugly ass code.

commented: Rude and unhelpful -3

goddamn that's some ugly ass code.

yes it is, and I can assure you, he would have written it a lot better if he wrote it himself, he just took the OP's code and corrected it so that it would work.
it may not be the best solution, but it's the easiest way to write a piece of code the OP will understand.

goddamn that's some ugly ass code.

excuse me, but havent u seen the title of this thread? im new to java... i still know nothing, and this guys right here are doing their best to help me...how come you can say things like that,, man , ur heartless.

excuse me, but havent u seen the title of this thread? im new to java... i still know nothing, and this guys right here are doing their best to help me...how come you can say things like that,, man , ur heartless.

You been given advice at the beginning to look into array, but rejected as to be difficult...
Secondly it took long time to get any code out of you. So please do not get touchy on comment, also would be nice if you actually thank to all these that helped you.

goddamn that's some ugly ass code.

My objective was to make the minimum changes necessary to make the code work. I deleted the formulas that were ... confused. And I put in a special way of handling 10 to 19. (The way we say "ten" to "nineteen" is a bit odd. But that's English for you! ;-)

Personally, I've always done this kind of thing with nested functions. And I don't like the "sloppy" capitalization and spacing of the results that this code produces. But my objective was to illustrate what it would take to make the existing program work.

commented: that you did +12

You been given advice at the beginning to look into array, but rejected as to be difficult...
Secondly it took long time to get any code out of you. So please do not get touchy on comment, also would be nice if you actually thank to all these that helped you.

sir i know i should be thankful to everyone who helped me, i am thankful! but this guy right here insulted the code that is one of the good persons here. Im sorry for my mistake, but i am just defending that one who helped me, because even though its very hard for me to understand the things that he is trying to explain, still, he was not discouraged, and i am thankful to that.

but this guy right here insulted the code that is one of the good persons here.

actually .. he made a comment on your code, not on JeffGrigg's code. and although his post didn't really serve to any good, he had a point, the code is messy, but that is to be expected from someone who's just starting and I don't doubt that your coding will improve a lot on the way.

but i am just defending that one who helped me.

what you actually did was: get upset about a post that didn't really matter. staying calm and ignoring insults will make it a lot easier to focus on your code :)

still, he was not discouraged

there are quite a few of us who weren't discouraged and willing to help, but there are a few things you should keep in mind:
you did kind of ignore a lot of the help offered. on monday, someone posted code like you needed, just limited to a number, but you could have implemented the rest yourself, you just didn't.
also, not being able to post answers all the time doesn't mean we're discouraged. we're all volunteers here, so we don't have all the time. we do have our own jobs or studies we may not neglect, and I'm pretty sure most of us also have kind off a social life (even though we're IT-people :) ).

but in the end, we're all happy you got your problem solved and hope you learned something while solving it.

actually .. he made a comment on your code, not on JeffGrigg's code. and although his post didn't really serve to any good, he had a point, the code is messy, but that is to be expected from someone who's just starting and I don't doubt that your coding will improve a lot on the way.

what you actually did was: get upset about a post that didn't really matter. staying calm and ignoring insults will make it a lot easier to focus on your code :)

there are quite a few of us who weren't discouraged and willing to help, but there are a few things you should keep in mind:
you did kind of ignore a lot of the help offered. on monday, someone posted code like you needed, just limited to a number, but you could have implemented the rest yourself, you just didn't.
also, not being able to post answers all the time doesn't mean we're discouraged. we're all volunteers here, so we don't have all the time. we do have our own jobs or studies we may not neglect, and I'm pretty sure most of us also have kind off a social life (even though we're IT-people :) ).

but in the end, we're all happy you got your problem solved and hope you learned something while solving it.

yes sir, i understand thank you, i appreciate all the help, and some of the codes that some posted here were a lot of help but i did not ignore it, its just that i cant do it because the only thing that i know is if else so, i did not do it, :( im sorry sir, if i did something wrong but i am thankful specially for u because u were there since the very beginning thank u sir.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.