Here is the output that I should be receiving:

Please enter the name on the check (First Last): John Doe
Please enter the amount for the check (as a float): 123.45
 ---------------------------
Pay to : John Doe           $123.45 
one hundred twenty three dollars and  45 cents

Now, what I am having problems with is turning the $123.45 into one hundred twenty three dollars and 45 cents.

Thanks for your help,
- Aepexx

Recommended Answers

All 9 Replies

Post the code you have to start with. Ask specific questions about what you are having trouble with and what you have tried so far.

have you written anything yet? show us what you've got so far, don't wait until we write it for you

Here is what I have written so far:

import java.util.Scanner;
public class Asn8
{
	public static void main(String args[])
	{
		Scanner kb = new Scanner(System.in);
		String s1;
		System.out.println("Please enter the name on the check (First Last) : ");
		s1 = kb.nextLine();
		System.out.println("Please enter the amount for the check (as a float) : ");
		float f1 = kb.nextFloat();
		if(f1 < 0)
			System.out.println("Invalid amount : " + f1);
		System.out.println("\n------------------------------------------------------");
		System.out.println("\nPay to : " + s1 + "\t\t\t\t$" + f1);
	}
}

... and? You now have some input to work with. What have you thought about doing with it?

How can you reduce that number to it's parts? You have to separate it before you can translate each to a string.

Are you trying to get at tokenizing it...? That's something that I had tried. I know how to tokenize from a String, but I don't know how to go about tokenizing a float to a string.

Actually I'm referring to basic math to break it down to it's parts. Just think about the steps you mentally go through to write it out your self and then write the statements to gather each piece, like hundreds, tens, etc.

I see what you're getting at. I can easily turn the 123.45 into one hundred twenty three...etc. What she wanted was for ANY sort of input to be turned into a string version of it. Not just specifically 123.45.

Sorry, I probably should have mentioned that earlier. But that's where I'm stuck at, turning any float into a written version of itself.

And that is what I was referring to.

How to you determine how many "hundreds" are in 123.45 (or other number)?
How many "tens"?
These are basic math operations.

Alright, thanks for your help. I'm just making it harder than it has to be. :P

Thanks again.

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.