View Single Post
Old 04-06-2012, 03:19 PM   PM User | #3
ckeyrouz
Senior Coder

 
ckeyrouz's Avatar
 
Join Date: Jun 2009
Location: Montreal, Canada
Posts: 1,044
Thanks: 5
Thanked 179 Times in 179 Posts
ckeyrouz is on a distinguished road
This is a simple sample on how to do it. You have to implement the same logic in your algorithm.

Code:
public class Asterisk
{
    public static void main(String[] args)
    {
        if(args.length == 0)
        {
            System.out.println("No arguments passed");
            System.exit(-1);
        }
        try
        {
            long value = Long.valueOf(args[0]).longValue();
            long hundreds = value / 100;
            System.out.println("number of asterisks ["+hundreds+"]");
            for(long i=0; i<hundreds; i++)
            {
                System.out.print("*");
            }
        }
        catch(NumberFormatException ex)
        {
            ex.printStackTrace();
            System.exit(-1);
        }
    }
}
__________________
Software and cathedrals are much the same - first we build them, then we pray.
ckeyrouz is offline   Reply With Quote