Aligning decimal points in columns

In my program I am writing I cannot seem to get the output to be formatted in the proper way. I need the columns to have the salary values aligned by their decimal points, by they are aligned to the left instead.
Like this:
Employee 1 2110.45 7-05-2004
Employee 2 55.09 7-05-2004
Employee 3 1100.00 7-05-2004
This is the code I am using to print:
public void printData() throws IOException {
          //Variable to read data from the text file
          BufferedReader in = new BufferedReader(new FileReader("EmployeeData.txt"));
        String str;
          Employee emp = new Employee();
          //Loop to read data from text file, alter salary, and print to monitor
          //Loop while there are lines remaining to read in text file
        while ((str = in.readLine()) != null) {
               //Variable to break up each line in text file by name, salary, and date
               StringTokenizer st = new StringTokenizer(str, "|");
               //Loop while there are more elements in the current line
               while (st.hasMoreElements()) {
                    //Retrieve name, salary, and date from the current line
                    String sName   = st.nextToken();
                    String sSalary = st.nextToken();
                    String sDate   = st.nextToken();
                    //Call function to calculate salary increase
                    double val = (new Double(sSalary)).doubleValue();
                    sSalary    = emp.calculateRaise(val);
                    //Print line to monitor
                    System.out.println(sName + "\t" + sSalary + "\t" + sDate);
        in.close();
}

If anyone wants to know how to align decimal points I
found the answer here:
http://leepoint.net/notes-java/25data/25strings/30conve
sion/54num2string.htmlThat is not a true way to align decimal points. It is only a way to right align text. If your decimals are irregular with some being .0, and others .00 or .000 this will not work. But, it will probably work for your problem.

Similar Messages

  • IN sharepoint 2013 custom list number type column ,decimal point shown as comma

    i have a sharepoint 2013 site in which a custom list is there. In number type field while i enter decimal number, instead of decimal point comma is comming. Any help appreciate
    Thanks sanjay

    Hi SanjayPradhan,
    According to your description, my understanding is that when type decimal point in number field, it became comma.
    I made a test in my enviroment and it works like a charm.
    Did you have some formula in that column ?
    If yes, I suggest you can check the formula in list settings->columns.
    If No, I suggest you can recreate a new list and number field to test whther it works.
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • Adding a decimal point to a number column

    I have a column defined as number(10,2)
    I've imported data to this column from a betrieve database which did not use decimal points, so my data looks like this:
    13000
    2000
    I need to update this column and place a decimal point in front of the last two zeros, so the new data would look like this:
    130.00
    20.00
    Any suggestions on the best way to accomplish this?

    yes, all the data ends with double zeros and all the data is end the same format.
    I gotcha! There is no need to insert a decimal if I divide the 100! Dah!
    Thanks!

  • Decimal Point data for Stacked Column Chart

    Hi,
    I use a basic version of a Column chart for one of my projects. I use a stacked column chart with 2 data series namely "Expenses" & "Profit".
    I use decimal point numbers (with only two or three places after the decimal point) for both series.
    When I mouse over the bars of the output for tool tip, I view more numbers after the decimal point for some data.
    How to fix the decimal point to only 2 places & what is the reason for this behaviour?
    Attached is the sample output (output.gif) showing the above condition for the mentioned data.
    -Sen

    Create an toolTipShow event handler and use a NumberFormatter to set the precision of the numbers (sample code from LiveDocs):
    <?xml version="1.0"?>
    <!-- formatters\MainNumberFormatter.mxml -->
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:Script>
            <![CDATA[
                // Define variable to hold the number.       
                [Bindable]
                private var bigNumber:Number = 6000000000.65;
            ]]>
        </mx:Script>
        <!-- Declare and define parameters for the NumberFormatter.-->
        <mx:NumberFormatter id="PrepForDisplay"
            precision="0"
            rounding="up"
            decimalSeparatorTo="."
            thousandsSeparatorTo=","
            useThousandsSeparator="true"
            useNegativeSign="true"/>
        <!-- Trigger the formatter while populating a string with data.-->
        <mx:TextInput text="{PrepForDisplay.format(bigNumber)}"/> 
    </mx:Application>

  • Convert the money datatype to a 2 decimal point format.

    Whats the best way to convert the money datatype to a 2 decimal point format in ms sql 2005 for use in my applications.
    this?
    CAST(tr.depositReceivedAmount AS decimal(10 , 2))

    I respectfully disagree with the notion that you should change the SQL column from a 'money' data-type to something else.
    In most database servers, 'money' is a data type that is designed to provide very consistent behavior with regard to arithmetic accuracy.  In Microsoft Access, the representation is a scaled-integer.  In MS SQL Server, it is obviously similar.  Ditto Oracle and all the others.
    You want the money data-type in the database to have this accuracy, because "hell hath no fury like an accountant in search of one lousy penny."   The database column storage-formats are designed to satisfy accountants, and that is a Good Thing.
    Meanwhile, you also want to take care as to exactly how you deal with the values.  There are several points where rounding could take place.  You do not have at your disposal the strongest possible handling of floating data-types in ColdFusion.  You are also somewhat at the mercy of whatever interface software may lie between you and whatever SQL server you may use.  "It's okay to round values once, but not multiple times."
    I suggest rounding the value right before display, and stipulating that the user's input must be two decimal places.
    Then, you might have to do some things at the SQL server's end.  For instance, when you update a value in the table, you may need to use server-side logic to explicitly truncate the value to two decimal-points, so that an update of "$34.56" explicitly updates the column to "$34.5600."  (This sort of thing has to happen within the SQL server context.)  You know that the user's input has exactly two significant digits, but maybe (maybe not...!) the SQL server might not know this.  You want to ensure that the server's internally-stored value represents exactly two significant digits, when the value originates from a user-input.
    Don't err on the side of "your convenience" or "what looks good on-screen."  (If you do, get ready to get phone-calls from the accountants, always at inopportune hours of the night.)

  • OBIEE 11.1.1.6 - Requirement is to show 3 digits after the decimal point.

    Hi,
    I have a requirement to concat 2 columns ( 1st column is a text column and 2nd column is a numeric column set as double in RPD). For the 2nd column, user wants to see 3 decimal digits all the time.
    For example, if the value is 2.4567 then I need to show round off value 2.457 and if the value if 3.4 , then I need to show 3.400 and if the value is 4 then I need add decimal point and show 4.000.
    Please let me know how I can achieve using OBIEE application without having to go through RPD.
    Thanks
    Swarna
    Edited by: 934460 on May 15, 2012 12:48 PM

    Try the following:
    In this example:
    Column 1: Month Name
    Column 2: Revenue
    Column 3: Month - Revenue
    Formula for Month - Revenue column will be:
    Month Name ||' - '|| cast(round(Revenue, 3) as char)Hope it helps.
    Regards,
    Kalyan Chukkapalli
    http://123obi.com

  • Can't figure out how to solve the decimal point bug in this calculator code

    Hi guys, I'm new in flash and is currently learning how to build a simple calculator with multipliers (plus,minus,multiple,divide,decimal point and change sign) but I'm stuck on the decimal point and change sign.
    var multiplier_old:Number = 10;
    var multiplier_new:Number = 1;
    // .: Sets the multipliers so that new input numbers become decimals of a lower unit column
    action_point.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
              multiplier_old = 1;
              multiplier_new = 0.1;
              point = true;
    // Takes intput from the input_ buttons and adds it to the input after applying the multipliers.
    // If `point` is true then the multiplier_new is divided by 10, also as described.
    function inputNumber(n:Number):void {
              input = input * multiplier_old + n * multiplier_new;
                        if (point) {
                                        multiplier_new *= 0.1;
                       trace(multiplier_new);
              output_txt.text = input.toString();
    Decimal point
    The problem is that when I input 2.7 in the calculator, it will display the values in output_txt correctly. But then when I input 2.78, it will display 2.780000000000000000000000002. This will also happen to other numbers if the input is too big.
    What I want is just 2.78. How do I change the codings to make 2.780000000000000000000000002 become 2.78?
    Change sign
    Any tips on how to start on this one?
    Thanks for your time,
    Zainu

    I think you misunderstand what I mean. The weird decimal doesnt comes out after I press the 'equals' sign. It comes out when im just pressing on the caculator number buttons
    First I click the no.2 button and then the decimal point button.
    So the caculation output display will show
    2.
    after that I press the no.7 button
    2.7
    and then no.8 button. It appears like
    2.7800000000000000002
    This is the code I use when the user press the decimal point button.
    // .: Sets the multipliers so that new input numbers become decimals of a lower unit column
    action_point.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
              multiplier_old = 1;
              multiplier_new = 0.1;
              point = true;
    // Takes intput from the input_ buttons and adds it to the input after applying the multipliers in the method described above.
    // If `point` is true then the multiplier_new is divided by 10, also as described.
    function inputNumber(n:Number):void {
              input = input * multiplier_old + n * multiplier_new;
                        if (point) {
                                 trace(multiplier_new.toFixed(3));
                                  multiplier_new *= 0.1;
                                  //trace(multiplier_new);
              output_txt.text = input.toString();
    I think there is some code wrong in this function that makes this weird problem. I tried putting toFixed method but it's still not working.
    Sorry for this long reply but I have to try my bestto explain with my bad english.

  • How to use os x yosemite calculator - need decimal points

    I updated to OS X Yosemite version 10.10.2 for my Mac.  I cannot figure out how to use the calculator!  All I want is to add dollars and cents.  How do I get a decimal point?  I've searched the web and don't see this addressed.

    I double checked.  No decimal point anywhere!  I tried typing in a number with a period….nothing.
    Along the top row it has ASCII, Unicode, Show Binary buttons and 8, 10, 16.  I tried them all. 
    I have AND , OR, NOR, XOR, <<,>>, X<<Y, X>>Y, bite flip, word flip in the first two columns. Letters and numbers in the next three columns, and AC, C, RoL, RoR, 2's, and 1's buttons along with math operation symbols in the last 2 columns.
    I can't believe I can't just add up numbers with decimals when doing simple math!
    Any other ideas?
    Thanks.

  • How to delete trailing zeros after the decimal point in the ALV sum

    Hello Expert,
    In my alv output, I need to sum up one column, but in the sum result, I don't want to display zeros after the decimal point.
    for example,
    If the sum is 134.00, I only want to display 134 on the alv.
    Does any expert have idea about it?
    Thanks in advance,
    best regards, Johnny

    Hi ,
    Use following
    SHIFT variable RIGHT/LEFT DELETING TRAILING '0'.
    For more variations ,
    just write SHIFT and press f4 , it will show you the information you need.
    Hope this is helpful,
    Regards,
    Uma Dave

  • Remove decimal points

    Hi,
    how to remove decimal points from all the columns in table in obiee
    thanks

    hi
    add one decimal point
    is this the same? or any?
    Cheers

  • Decimal points - geometry - sql developer georapter

    Hi
    I have loaded shape files with SQL developer Georaper and limited number of decimals to 8. There is option to limit number of decimals in georapter.
    But there are some X, Y with many decimals. This may create problem in spatial functions in which geometries are compared and filtered.
    Please suggest me how to control the decimal points of X,Y to be loaded in geometry column.
    -0.4695623500000000172249770002963487058878                    51.47160360000000167701728059910237789154
    -0.4702653600000000211345252409955719485879                    51.47174944999999723904693382792174816132
    -0.4713475400000000092859409051015973091125                    51.47330664999999783049133839085698127747
    -0.4717886499999999760923685698799090459943                    51.47432505999999818868673173710703849792
    -0.4727564499999999947377204989606980234385                    51.47439456000000035373886930756270885468
    -0.4710064700000000104118669241870520636439                    51.4703249599999992369703250005841255188
    -0.4713933299999999992913046753528760746121                    51.4707325999999980581378622446209192276
    -0.4708402500000000157065471739770146086812                    51.46869396999999679565007681958377361298
    -0.48199913                            51.47069623
    -0.48186682                            51.47069561
    -0.48186696                            51.47070972
    -0.48186738                            51.47073525
    -0.48186786                            51.47076416
    -0.48204026                            51.47076313
    -0.48205911                            51.47077464
    -0.44306117                            51.45944246
    -0.44311694                            51.45944362
    regards

    Don,
    Search is your friend. Simon has a function to do this, please see this thread:
    https://forums.oracle.com/thread/2378661
    Bryan

  • Answers Decimal Points

    When I'm in answers it is by default rounding all of my dollar amount columns to one decimal point.
    Ex: Amount = $17.55 (on the database) is rounding to $17.6 in my Answers result.
    I know that I have the ability to edit the format in Answers to override the result (specify two decimal points). However, i would like to set it up so that it is by default always producing two decimal points.
    Where would I set this up?
    Thanks...

    hi ,
    we can set the in administator tool or answers also
    administrator tool
    click the column properties
    use the round function in expression Biulder.
    apply the round function wit 2
    and go to presentation services
    and change data formates what we required

  • Sqlldr ( sqlloader ), why not loading decimal point properly ?

    Hi,
    I am trying upload data using sqlldr ( sql loader ) in Oracle 9.2 in AIX, Details are
    Table
    drop table parag;
    CREATE TABLE parag
    source_sys char (00006) not null,
    portfolio_FO char (00006) not null,
    prod_id char (00016) not null,
    V00230 char (00003) not null,
    inst_id char (00008) not null,
    V09490F char (00016) not null,
    V09060 number (15,2) not null,
    V09040 char (00008) not null,
    V09000 char (00008) not null
    GRANT ALL ON parag TO PUBLIC;
    Control File
    load data
    infile '$A2_FIC/parag.dat'
    replace
    into table parag
    fields terminated by ',' trailing nullcols
    source_sys,
    portfolio_FO,
    prod_id,
    V00230,
    inst_id,
    V09490F,
    V09060 decimal external
    V09040,
    V09000
    Data
    F01,1517,BROK4,INO,FXSPT,0,-182867.10,20080331,20080331
    F02,7822,BROK4,INO,FXSPT,0,-1765629.15,20080331,20080331
    F03,1515,STFXSPTFWD,EUR,FXD,48486608,-4652.20,20080331,20080331
    F04,1515,STFXSPTFWD,INO,FXD,48486608,274003.25,20080331,20080331
    F05,1515,STFXSPTFWD,INO,FXD,48485733,1504906.30,20080331,20080331
    F06,1515,STFXSPTFWD,INO,FXD,48549114,7498008.35,20080331,20080331
    F07,1515,STFXSPTFWD,INO,FXD,48548049,40765000.40,20080331,20080331
    F08,1515,STFXSPTFWD,INO,FXD,48485744,80125030.45,20080331,20080331
    F09,1515,STFXSPTFWD,INO,FXD,48552707,-2768610.50,20080331,20080331
    F10,1515,STFXSPTFWD,INO,FXD,47923730,-6268500.55,20080331,20080331
    F11,1515,STFXSPTFWD,INO,FXD,48179724,-9870000.60,20080331,20080331
    F12,1515,STFXSPTFWD,INO,FXD,47404500,-13656000.65,20080331,20080331
    But my result is showing,
    SQL> /
    SOURCE V09060
    F01 -182867.1
    F02 -1765629.2
    F03 -4652.2
    F04 274003.25
    F05 1504906.3
    F06 7498008.35
    F07 40765000.4
    F08 80125030.5
    F09 -2768610.5
    F10 -6268500.6
    F11 -9870000.6
    F12 -13656001
    12 rows selected.
    Questions
    1/ My table column v09060 is 15,2 is this short ? ( looks like ) but not understood for e.g. F02, v09060 data including decimal point is 10 while in my table it is 15,2
    2/ How to overcome this problem ? without giving V09060 "to_number(:v09060,'999999999999.99')", in control file
    Pl guide me.
    thanks & regards
    parag

    Hi,
    Sorry could not understood the reason. Will you pl expalain me ?
    1* select source_sys, v09060, length(v09060) from parag order by 1
    SQL> /
    SOURCE V09060 LENGTH(V09060)
    F01 -182867.1 9
    F02 -1765629.2 11
    F03 -4652.2 7
    F04 274003.25 9
    F05 1504906.3 9
    F06 7498008.35 10
    F07 40765000.4 10
    F08 80125030.5 11
    F09 -2768610.5 10
    F10 -6268500.6 11
    F11 -9870000.6 10
    F12 -13656001 12
    12 rows selected.
    F01,1517,BROK4,INO,FXSPT,0,-182867.10,20080331,20080331
    F02,7822,BROK4,INO,FXSPT,0,-1765629.15,20080331,20080331
    F03,1515,STFXSPTFWD,EUR,FXD,48486608,-4652.20,20080331,20080331
    F04,1515,STFXSPTFWD,INO,FXD,48486608,274003.25,20080331,20080331
    F05,1515,STFXSPTFWD,INO,FXD,48485733,1504906.30,20080331,20080331
    F06,1515,STFXSPTFWD,INO,FXD,48549114,7498008.35,20080331,20080331
    F07,1515,STFXSPTFWD,INO,FXD,48548049,40765000.40,20080331,20080331
    F08,1515,STFXSPTFWD,INO,FXD,48485744,80125030.45,20080331,20080331
    F09,1515,STFXSPTFWD,INO,FXD,48552707,-2768610.50,20080331,20080331
    F10,1515,STFXSPTFWD,INO,FXD,47923730,-6268500.55,20080331,20080331
    F11,1515,STFXSPTFWD,INO,FXD,48179724,-9870000.60,20080331,20080331
    F12,1515,STFXSPTFWD,INO,FXD,47404500,-13656000.65,20080331,20080331
    SQL> desc parag
    Name Null? Type
    SOURCE_SYS NOT NULL CHAR(6)
    PORTFOLIO_FO NOT NULL CHAR(6)
    PROD_ID NOT NULL CHAR(16)
    V00230 NOT NULL CHAR(3)
    INST_ID NOT NULL CHAR(8)
    V09490F NOT NULL CHAR(16)
    V09060 NOT NULL NUMBER(15,2)
    V09040 NOT NULL CHAR(8)
    V09000 NOT NULL CHAR(8)
    thanks & regards
    parag

  • Extending decimal points on timestamp for write to measuremen​t file .vi

    Hello Everyone
    Currently I am collecting a bunch of Fieldpoint Channels in LabVIEW (about 190) which is a lot of instrumentation. Right now we want to be sure the computer can keep up and read all of the channels every second. To test this theory I want to use the WTMF to get a timestamp for every channel (seems to be the easiest way).
    While reading the file I get like 5.68 so two decimal places. I was wondering if there was a way to get a more accurate time reading down to the millisecond. I know this is three places after the decimal point, but I was hoping I could extend this to 5-6 places past the decimal point.
    Usually when saving data I use the write to spreadsheet with one time column and can just format the readings through that, but for some reason I cannot figure this out with the WTMF
    If there is any input to check these time differences besides doing the above, that would also be appreciated.
    Any input would be amazing.
    Thanks so much
    Tanya

    Hi vaib,
    as i said already here, http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=332115#M332115 i think you can´t stop the writing process. If you start them, then you have to wait til the vi is ready. To measure the time you can use the "Tick count" function. See the attached picture.
    Mike
    Message Edited by MikeS81 on 06-17-2008 03:34 PM
    Attachments:
    Unbenannt1.PNG ‏12 KB

  • Make one number after the decimal point

    hi all
    i have a column named quantity from the table job_done
    with values
    1900.8988
    34.67
    0.6788
    236.67
    789999.67676868
    i require the values to be 1900.8
    34.6
    0.6
    236.6
    789999.6
    i just require one number after the decimal point,i know substr but i am confused as to how to achieve this output
    kindly guide
    thanking in advance

    http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions221.htm#SQLRF06150
    Regards
    Etbin
    Edited by: Etbin on 5.5.2013 14:33
    <tt>substr(quantity,1,instr(quantity,'.') + 1)</tt> if those are not numbers but all contain a decimal point
    Edited by: Etbin on 5.5.2013 14:40
    <tt>case instr(quantity,'.') when 0 then quantity else substr(quantity,1,instr(quantity,'.') + 1) end</tt> when there are no <tt>null</tt> values
    <tt>trunc(to_number(quantity),1)</tt> seems to be the safest if quantities are really <tt>to_char(some_number)</tt>

Maybe you are looking for

  • Windows 7 home premium_service pack 1_"windows update_80240016"

    can some one please help me. my pc is a hp 64bit windows 7 home premium. everytime I try to update with srvice pack 1 it fails and i get "windowsUpdate_80240016" "windows update_dt000"  try again ????? can anyone help??

  • Field value is truncated while downloading to excel sheet from ALV report

    Hi All, I developed ALV report and displaying output. In that output i had a filed VBRP-PRODH filed. In the output it is coming correctly but while i click downlaod to excel the valus is truncted. for Example the value for VBRP-PRODH is 0332276417010

  • IPhone 3G will not sync after recent update to software

    I began a sync for my phone and new software was available and I allowed the update. Now my iPhone 3GS will not sync. continues to give an Unknown Error -39. What do I do?

  • Product hierarchy in select-options.

    Hi Everyone, I am using Product hierarchy in select-options.When I run the report for the range of 001500015100015102 to 002500025300025302,It works .However, if i enter just 00150 to 00250 and select the Product Hierarchy 3 (2 or 1) level, i am gett

  • Running 9iAS in console? Develop/debug configuration

    I'm in dev/debug mode so I want to work with a running console to see my log4j logging working. I previously used a small install of OC4J and just ran java -jar oc4j.jar to get a console up and running. I've now got 9iAS installed and I've tried shut