Social Icons

Monday, December 24, 2012

Comma separation code in Java




Displaying large figures without comma separation is quite daunting to the users. For an example just think how hard to discern the value of 9501625237.56 ? Instead of displaying such number as it is we can format the said value using commas which would be more readable , like this  9,501,625,237.56 If displayed likewise An user wouldn't have to waste time deciphering such lengthy values. Here is the code I wrote to accomplish this output using Java to utilize into much larger programs. The method can be overridden or overloaded as you would deem necessary. 

Input : Takes the value to be formatted as a  String object.
Returns: Formatted value as a String object.
private String addCommas(String strn){

         String commaSeparatedNumber="", decimals="";
        //split contents before the decimal point

        commaSeparatedNumber = strn.contains(".") ?   strn.split("\\.")[0] : strn;
        decimals = strn.contains(".") ? "."+strn.split("\\.")[1] : "";

        /*create a regular expression for the thousand separator, store those matches separately for the replacement.*/
        String regx="(\\d+)(\\d{3})";

        //create pattern and matcher objects to find matches
        Pattern p = Pattern.compile(regx);
        Matcher m = p.matcher(commaSeparatedNumber);

        //iterate to find the next match.
        while(m.find()){
            //replace the found matching groups with the comma.
            commaSeparatedNumber = commaSeparatedNumber.replaceFirst(regx, m.group(1) +","+ m.group(2));
            //update the matcher with new replacements.
            m = p.matcher(commaSeparatedNumber);
        }

        return commaSeparatedNumber+decimals;
    }


Monday, September 24, 2012

Average Cost Calculator - Redefined




Hey there Fellow readers, After an interval I have some time to look into Trading calculators one of these days. Hence fresh improvements in my projects can be expected in coming weeks. First of such improvements goes in to Average Cost calculator, wherein I have made major overhaul in the code. So the changes may not be apparent. But the UI looks good , the code looks good so I feel much better. And I'm pretty confident that It could be made to a more robust application. Major changes was made to JS code to optimize and avoid redundancies. Data structures have been utilized to store contracts so that all the transactions can be viewed using The Trades button, which is a new addition to the previous version. Number of  Trade types have been increased to 4 where Day-Sell and Day-Buy options are included. User can opt to add brokerage to the first contract if the calculated average price is available. This is indeed the case most of the time since the average costs are included in the most portfolio statements. Await for further changes and improvements .Cheers.

Saturday, July 14, 2012

KMPlayer 3D: A Whole new look , feel and capabilities.



untitledfff  
KMPlayer is all in one media player, covering various formats such as VCD, DVD, AVI, MKV, Ogg Theora, OGM, 3GP, MPEG-1/2/4, WMV, Real Media, and QuickTime. It has an extra feature to play Incomplete/Damaged AVI file, Locked Media Files while downloading or sharing, Compressed Audio Album (zip, rar) and so on. It handles a wide range of subtitles and allows you to capture audio, video, and screenshots in many ways. The player provides both internal and external filters with a fully controlled environment without grappling with DirectShow merit system. The player can set multifarious audio and video effects, control playback speed and octave, select parts of a video as favorites, do a powerful A-B repeat, remap the keys of remote interface for HTPC including overlay screen controls, change a skin dynamically depending on a media type playing, and many more. It is completely customizable thanks to a wide selection of skins and color schemes, and configuration options are extensive. KMPlayer is one of the most powerful video players in the world and trying to offer the best media entertaining environment for users. With new vision and dedication for the better user experience of video entertaining, we will keep listen and communicate with users of KMPlayer
untitled

Sunday, June 10, 2012

Profit_Loss Calculator major UI Update


untitled


Profit&Loss calculator has been undergone a rapid update schedule these days and today I modified the structure of the program entirely to facilitate better user experience and versatility. and furthermore on the script I have added Interest calculation feature to cater more accurate cost calculation but of course I made those fields optional so that you may leave them blank. more updates can be anticipated on this week.
                 On this week I added a simple but useful feature. as you know orders aren’t always filled in full quantities for an example if we place a sell order for some 1000 shares this quantity may get executed by parts of 100,500,233,…etc so In such events you don’t need to calculate how many shares have been sold separately. In the sell quantity text fields just enter the quantities separated by ‘+’ operator and the total sold quantity will be calculated on the fly.  (see the image below)
 
Untitled-1 copy

Furthermore I have added profit calculation and Quantity calculation features. which facilitates investor and alike to make their trading experiences more fruitful. More updates are coming up. Enjoy folks. Happy trading.

Sunday, May 20, 2012

Introducing - Average cost calculator for CSE equity trading




After playing around with my Profit/Loss calculator for few weeks I decided to develop this simple yet useful average cost calculator for equity trading in CSE. The Scenario is quite straightforward , An investor already has X amount of ABC shares at an averaged price of Rs. P1 and he needs to know what will be the average price if he buy Y  amount of ABC shares at Rs. P2. or sell Z ( where Z<=X) amount at Rs P3. 
If you are tangled in the above scenario , then Average price calculator is the solution for you. please note that the Average price calculator works only with Mozilla Firefox and Google Chrome. I'm having an issues getting it work on IE. Please make sure to check out my Profit/Loss calculator as well.


 
 
Blogger Templates http://slots.to/