Output number is wrong when inputing number w/commas

I've been working on this code for less than a week and have been able to make it work like I need it to except when I input numbers with commas (the loan amount) or I'll get an error when I type in "%" for the interest. Any ideas on what I've done wrong to fix these two errors? I thought the while statement was the problem for the comma error, but that part was given to me so it shouldn't be wrong. Any and all help would be much appreciated. Thanks in advance.
BTW, it compiles just fine and will do what I want it to if I leave off the commas and the "%" sign... but the instructions are to enter both the commas and "%" as part of the inputs.
I think this is where the code goes awry... but I'm not sure.
          // Substrings
          principalAmount = principalAmount.substring(principalAmount.indexOf('$')+1);
          principalAmount = principalAmount.substring(principalAmount.indexOf(',')+1);
          interestAmount = interestAmount.substring(interestAmount.indexOf('%')+1);
          interestAmount = interestAmount.substring(interestAmount.indexOf('.')+1);
          // convert string to #
          principal = Double.parseDouble(principalAmount);
          interest = Double.parseDouble(interestAmount);
          interest = interest / 100;
          years = Integer.parseInt(yearsAmount);
          // While statement
          while (principalAmount.indexOf(',') >= 1)
               principalAmount = principalAmount.substring(0,principalAmount.indexOf(','))
               + principalAmount.substring(principalAmount.indexOf(',')+1);
          

@flounder
Isn't that what I'm doing by using the substrings? Sorry, I'm a bit confused on how to strip out and calling the parseDouble.
@CaptainMorgan08
I was told that by someone else... but I haven't learned what that is yet. In my book, that's in chapter 9, but I've only gotten to chapter 4...
Message was edited by:
Tsurara

Similar Messages

  • Output number with comma separator

    I have the value 1250 as an amount in a smartform.  And I want to output this as 1,250.  How do I do this?

    Hi...
    Use this function module.....
    it will satify your requirements...
    pass that changing parameter to the smartform..
    DATA: v_cur like TCURX-CURRKEY,
            c_cur(10) type c VALUE '1250'..
      CALL FUNCTION 'SD_CONVERT_CURRENCY_FORMAT'
        EXPORTING
          i_currency                  = v_cur
    *   IMPORTING
    *     E_CURRENCY_INT_FORMAT       =
        changing
          c_currency_ext_format       = c_cur
       EXCEPTIONS
         WRONG_FORMAT                = 1
         OTHERS                      = 2
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      WRITE: C_CUR.
    I believe this will greatly help you.
    Thanks and regards
    Bhuvana

  • Input Tax and Output Tax calculating wrong figures

    Hi,
    I have created Input Tax and Output Tax codes in SAP.
    Input Tax- 3%
    Output Tax- 4%
    All the configuration is done as required. But when I am posting the Purchase and Sales Invoice, the tax amount is not calculating correctly.
    For example:
    Input Tax Calculation should be:
    Vendor A/C.............. Cr 30000-
    Expense A/C............ Dr 29100
    Input Tax A/C............ Dr 900 (@3% on 30000)
    Input Tax Calculation in SAP:
    Vendor A/C.............. Cr 30000-
    Expense A/C............ Dr 29126.21
    Input Tax A/C............ Dr 873.79 (@3% on 30000)
    The same is happening to Output Tax transactions.
    Please advice.

    My understanding about the Input Tax and Output Tax was wrong. In the issue reported
    Input Tax Calculation should be:
    Vendor A/C.............. Cr 30000-
    Expense A/C............ Dr 29100
    Input Tax A/C............ Dr 900 (@3% on 30000)---my understanding was wrong.
    Input Tax 3% should be charged on Expense amount, in this case Rs 30000. But because in the editing option calculate tax on net amount option was not selected, hence SAP was giving the below entry, which is correct as well.
    Vendor A/C.............. Cr 30000-
    Expense A/C............ Dr 29126.21
    Input Tax A/C............ Dr 873.79 (@3% on 29126.21) which is correct.
    Hence, the Vendor amount should be Expense + Input Tax= 30000 * 3%=900 + 30000 (expense) = 30900.
    Correct Entry should be:
    Vendor A/C...............Cr 30900
    Expense A/C............Dr 30000
    Input Tax A/C............Dr 900
    Resolved. Pankaj has given the correct answer.

  • Color wrong when printing to Canon i9950 from CS5 apps and Acrobat, Win7 x64

    When printing from InDesign CS5 on Win 7 x64 to Canon i9950 using the  Canon ICM profiles (MP1, PR1, PR2, SP1) the colour output is completely  wrong!
    I disable the printer driver in the print prefs  (set to "manual") and under "color management" choose "Let InDesign  decide..." (no other option) for "color handling", and choose one of the  above profiles for "printer profile", as appropriate to the paper in  the printer, and the colours are totally out of whack.
    If  I just set the output "printer profile" to "Adobe RGB (1998)" the  output is much better, but of course it still isn't quite correct, or  properly set for the individual substrates, which the Canon ICMs are  supposed to do.
    Interestingly, when setting output to the  Canon profiles, it makes no difference whether the printer manages  colour (auto) or not (manual). Also, strangely, these profiles were  working fine with CS4, before installing CS5, but now they are not  working in CS4 either!
    So now "colour management" is a joke thanks to CS5.

    You might check with Canon to see if they've prepared any updated printer drivers you can download and install.
    Scout around this forum, a number of folks have reported certain Epson models with similar issues.  Feedback from Adobe was that they've switched to newer printer interfaces under the covers, and not all printer drivers work properly with those interfaces.  In one case at least a new printer had to be purchased to fix the problem.
    -Noel

  • HT201272 i want to dowmload apps and it tells me to review my account i put my bank detalis in and its telling me it wrong when its not

    I want to download apps it tells me to review my account. when i do this it asks for my bank details i put them in and its telling me there wrong when its not.. how do i fix this?

    What sort of card are you trying to add ? There have been a number of posts recently from people having debit cards declined, so I'm not sure if they are still accepted in the store - they are not listed on this page as being a valid payment method.
    If it's a credit card then is it registered to exactly the same name and address (including spacing and format) as you have on your iTunes account, and you are currently in that country ? If it is then you could try contacting iTunes Support and see if they can help with it's not being accepted : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • HP Photosmart 7200 Colors are Wrong When Printing on Photo Paper

    I'm running Windows 7 and am having a problem when printing on photo paper.  The colors are off; mainly green.  The colors are fine when printing on plain paper.  I have tried printing from my computer as well as straight from the media card.  Same result.  I am also using HP Photo Premium glossy paper.  Print cartridges are brand new and are loaded correctly.
    Any solutions or troubleshooting tips I can try?

    Hi @Vay725,
    Welcome to the HP Forums!
    I understand that the colors are wrong when printing on photo paper! I am happy to help you with this print quality issue!
    For further assistance, I will need to know some more information:
    The Product/Model Number of your printer. Follow instructions in this link. Finding Your HP Product Model Number.
    If you are using a Windows or Mac Operating System, and the version number. To find the exact version, visit this link. Whatsmyos.
    If the printer is connected, Wireless, or USB.
    If the printer is able to make copies.
    If the power cable is plugged into a surge protector, or directly to the wall outlet. Issues when Connected to an Uninterruptible Power Supply/Power Strip/Surge Protector. This applies to Inkjet printers as well. 
    If you are using Genuine HP Ink cartridges.
    Thank you for posting, and have a nice day!
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

  • Covert number to comma separated number

    I have to covert number to comma separated number
    Please let me know how to do this.
    Example :
    Input: 10000 Output: 100,00
    Input: 1000 Output: 10,00
    Input: 1000044 Output: 100,00,44

    Like this
    with t as
    ( select 1234 a from dual union all
      select 1234456 from dual union all
      select 123 from dual union all
      select 12 from dual union all   
      select 124579652 from dual union all
      select 12235 from dual
    select to_char(a,'999,99,99,99,99,99') formatted
      from t Regards
    Arun

  • Something wrong when installing then demo database schema

    rdbms server 9.2.0.5 win32
    jdev904
    bibeans904
    Something is wrong when installing the demo database schema.While executing cwm2_olap_metadata_refresh.mr_refresh at last ,system hint that cwm2_olap_metadata_refresh.mr_refresh must be declared.That means there is not cwm2_olap_metadata_refresh.
    Why and What should I do ?
    Thanks a lot!

    After executing the file catpatch.sql,the demo database schema completed successfully.But there is something wrong during bi_checkconfig.
    BI Beans Diagnostics(v1.0.2.0) 04-6-30
    ==========================================================JDEV_ORACLE_HOME .......................... = d:\jdev904
    JAVA_HOME ................................. = d:\jdev904\jdk
    JDeveloper version ........................ = 9.0.4.0.1419
    BI Beans release description .............. = BI Beans 9.0.4 Production Release
    BI Beans component number ................. = 9.0.4.23.0
    BI Beans internal version ................. = 2.7.5.32
    Connect to database ....................... = Successful
    JDBC driver version ....................... = 9.2.0.4.0
    JDBC JAR file location .................... = D:\jdev904\jdev\lib\patches
    Database version .......................... = 9.2.0.5.0
    OLAP Catalog version ...................... = 9.2.0.5.0
    OLAP AW Engine version .................... = 9.2.0.5.0
    OLAP API Server version ................... = 9.2.0.5.0
    BI Beans Catalog version .................. = N/A; not installed in bibdemo
    OLAP API JAR file version ................. = N/A
    OLAP API JAR file location ................ = d:\jdev904\jdev\lib\ext
    Load OLAP API metadata .................... = Unsuccessful
    Error: BIB-10100 Cannot connect to the database. (Reason: See error BIB-16626)
    ============================================================================
    1) BIB-10100 Cannot connect to the database. (Reason: See error BIB-16626)
    2) BIB-16626 Cannot connect to the database because OLAP client classes are missing.
    1) BIB-10100 Cannot connect to the database. (Reason: See error BIB-16626)
    ============================================================================
    oracle.dss.metadataManager.common.MetadataManagerException: BIB-10100 Cannot connect to the database. (Reason: See error BIB-16626)
         at oracle.dss.metadataManager.client.MetadataManager.setConnectionObjects(MetadataManager.java:4015)
         at oracle.dss.metadataManager.client.MetadataManager.attach(MetadataManager.java:862)
         at oracle.dss.metadataManager.client.MetadataManager.attach(MetadataManager.java:799)
         at BICheckConfig.checkConnection(BICheckConfig.java:277)
         at BICheckConfig.main(BICheckConfig.java:1348)
    2) BIB-16626 Cannot connect to the database because OLAP client classes are missing.
    ============================================================================
    oracle.dss.connection.common.ConnectionException: BIB-16626 Cannot connect to the database because OLAP client classes are missing.
         at oracle.dss.connection.server.drivers.mdm.MDMConnectionDriverImpl.connect(MDMConnectionDriverImpl.java:182)
         at oracle.dss.connection.server.ConnectionImpl.connect(ConnectionImpl.java:286)
         at oracle.dss.connection.client.Connection.connect(Connection.java:409)
         at oracle.dss.connection.client.Connection.connect(Connection.java:326)
         at oracle.dss.metadataManager.client.MetadataManager.setConnectionObjects(MetadataManager.java:3997)
         at oracle.dss.metadataManager.client.MetadataManager.attach(MetadataManager.java:862)
         at oracle.dss.metadataManager.client.MetadataManager.attach(MetadataManager.java:799)
         at BICheckConfig.checkConnection(BICheckConfig.java:277)
         at BICheckConfig.main(BICheckConfig.java:1348)
    What should I do ,any help?
    Thanks !

  • Display a number with commas

    Here's a way to display a number with commas. See attached
    code.
    I had searched here for help on how to do it, and couldn't
    find anything. So, then I wrote this. I'm a hack, self-taught
    coder, so there may be a more eloquent way, but this does
    work.

    Nice, I'm always happy to be humbled.
    One more point. If you're going ot use a return statement I
    like to keep it
    at the very end of the function. So, in a conditional
    statement, setting a
    local variable to the value to be returned allows you to
    return that local
    variable and always keep the return statement as the last
    line. It just
    saves a little searching around for returns in longer
    functions. Just a
    style choice not necessarily better.
    Craig Wollman
    Word of Mouth Productions
    phone 212 928 9581
    fax 212 928 9582
    159-00 Riverside Drive West #5H-70
    NY, NY 10032
    www.wordofmouthpros.com
    "duckets" <[email protected]> wrote in
    message
    news:[email protected]...
    >
    quote:
    Originally posted by:
    FasterPastor
    > I had searched here for help on how to do it, and
    couldn't find
    > anything.
    >
    > You should have asked! here's one I have had sitting
    around for a while.
    > (code
    > attached below). It handles lots of cases which the
    other handlers posted
    > so
    > far do not. Specifically:
    >
    > Negative numbers - input: -123456
    > - craig's: -,123,456
    > - dougs's: -,123,456
    > - mikes's: -,123,456
    > - duck's: -123,456
    >
    > Floating point numbers - input: pi
    > - craig's: 3
    > - dougs's: 3
    > - mikes's: 3.1,416
    > - duck's: 3.1416
    >
    > Numbers larger than the maxinteger - input: 149668992000
    > - craig's: -,654,863,360
    > - dougs's: -,654,863,360
    > - mikes's: 14,966,899,200,0.0,000
    > - duck's: 149,668,992,000
    >
    > Negative floats - input: -123456.7890
    > - craig's: -,123,457
    > - dougs's: -,123,457
    > - mikes's: -12,345,6.7,890
    > - duck's: -123,456.789
    >
    > Floats larger than the maxinteger - input:
    2233445566.7788
    > - craig's: -2,061,521,729
    > - dougs's: -2,061,521,729
    > - mikes's: 223,344,556,6.7,788
    > - duck's: 2,233,445,566.7788
    >
    > Yes.. the code is longer, but if you want to print
    something like the
    > distance
    > in meters to the sun, you need to handle floats
    properly!
    >
    > enjoy ;-)
    >
    > - Ben
    >
    >
    >
    > on stringNumber n
    >
    > outputString = ""
    > inputString = string(n)
    >
    > if inputString.char[1] = "-" then
    > negative = true
    > delete inputString.char[1]
    > else
    > negative = false
    > end if
    >
    > fraction = ""
    >
    > if inputString contains "e" then
    >
    > mantissa = inputString.char[1..(offset("e",
    inputString)-1)]
    > exponent = value(inputString.char[(offset("e",
    > inputString)+1)..inputString.length])
    >
    > decimalChar = mantissa.char[2]
    > mantissa = mantissa.char[1] &
    mantissa.char[3..mantissa.length]
    >
    > if mantissa.length < exponent+1 then
    > plainNumber = mantissa
    > repeat while plainNumber.length < exponent+1
    > put "0" after plainNumber
    > end repeat
    > else
    > plainNumber = mantissa.char[1..(exponent+1)]
    > fraction = mantissa.char[(exponent+2)..mantissa.length]
    > end if
    >
    > else
    >
    > if offset(".", inputString)>0 then
    > decimalChar = "."
    > end if
    > if offset(",", inputString)>0 then
    > decimalChar = ","
    > end if
    >
    > if offset(decimalChar, inputString)>0 then
    > plainNumber = inputString.char[1..(offset(decimalChar,
    > inputString)-1)]
    > fraction = inputString.char[(offset(decimalChar,
    > inputString)+1)..inputString.length]
    > else
    > plainNumber = inputString
    > fraction = ""
    > decimalChar = string(1.2).char[2]
    > end if
    >
    > end if
    >
    > if decimalChar = "." then
    > separatorChar = ","
    > else
    > separatorChar = "."
    > end if
    >
    >
    > repeat while plainNumber.char[1] = "0"
    > delete plainNumber.char[1]
    > end repeat
    >
    >
    > repeat while plainNumber.length > 0
    > if plainNumber.length > 3 then
    > nextDigits =
    >
    separatorChar&plainNumber.char[plainNumber.length-2..plainNumber.length]
    > delete
    plainNumber.char[plainNumber.length-2..plainNumber.length]
    > else
    > nextDigits = plainNumber
    > plainNumber = ""
    > end if
    > put nextDigits before outputString
    > end repeat
    >
    > repeat while fraction.char[fraction.length] = "0"
    > delete fraction.char[fraction.length]
    > end repeat
    >
    > if fraction.length > 0 then
    > put decimalChar&fraction after outputString
    > end if
    >
    >
    > if negative then
    > put "-" before outputString
    > end if
    >
    > return outputString
    >
    > end
    >

  • When my husband set up his new iPhone I read a message wrong when it popped up on my phone and now our messaging is synced. Is it because we have the same apple ID? Do we need to change that?

    When my husband set up his new iPhone I read a message wrong when it popped up on my phone and now our messaging is synced. Is it because we have the same apple ID? Do we need to change that?

    Yes, its best to have each individual apple ids. You can also go to settings, messages, send and recieve, start new conversation from, make sure there is a check mark beside each of your own individual email, not the same one on each phone.

  • For some reason the system is telling me my birth date is wrong when it's not and it won't let me proceed to reset my password. Can someone tell me how to get a "real" person from tech on line?

    For some reason the system is telling me my birth date is wrong when it's not and it won't let me proceed to reset my password. Can someone tell me how to get a "real" person from tech on line?

    contact itunes support

  • Item Cost FIFO was wrong when Goods Issue. How to slove it?

    Dear Experts,
    I met item cost of FIFO item was wrong when I did Goods Issue. The scenario is I did goods receipt from PO that item cost was 8.02 per unit. Then I saw in the inventory audit report that item cost was 8.02 per unit. That's right.
    But after that I did goods issue the item cost was 7.485 per unit. And I check to Journal Entry and Inventory audit report were posted the wrong item cost, 7.485 per unit. What source does the system bring to calculation item cost for goods issue?
    I access to SQL for check OINM and OITM table. Both of OINM and OITM's item cost were correct in the goods receipt transaction, but they booked wrong cost, 7.485 per unit, in goods issue transaction. I don't understand the logical that SAP B1 use to calculation item cost that use for goods issue.  In the past I think the table that related to item cost calculation was only OITM, OITW, OINM, but now I think I misunderstand it due to this case.
    Regards,
    Pornrat  Trisauvapak

    Dear Gardon,
    I use the FIFO for calculation and in this case has only one lot remain, that cost 8.02. Now I observe OINM table again all field are correct except OpenValue field. I'm not sure this field is related to item cost of goods issue, or not?
    Regards,
    Pornrat Trisauvapak

  • I accidentally turned on parental controls, when I try to turn them off it says my password is wrong when I know it's not. What do I do so that I won't have to wipe everything from my computer?

    Trying to fix something else in my settings I accidentally turned my parental controls on. When I tried to disable them it said my password or adminstrative name was wrong when I know they are both right. I even tried to change my password to the account but that didn't help. I don't want to have to delete my account and am not sure how to back everything up if that is the only option. Is there a simple solution to this?

    If you have Restricted your MAIN account in the perental controls that may be the reason. You may have to create a new Administrators account to change the settings on the parent controls.
    Not sure as I have never used that feature on any computer I own.

  • Facebook keeps saying sorry, something went wrong when try to open on my iphone

    Facebook keeps saying, sorry, something went wrong when I try to open it.  How can I resolve this issue?

    Same here, wife has been using her Facebook app all day, mine keeps giving me this stupid message, and this is the only other post any where i can find about this issue, thats not from 2010 or 2011. Guess its just going to have to be worked out, if its not resolved soon i guess ill just delete the app.

  • Displaying a number with commas in gid

    Hi EveryOne,
                       This is Ram Prasad.I want to display a number with commas in the grid (eg:1,000).In the grid it is shown as 1000.I wan to add commas for this number to be shown in the grid display template.Can any one help on this.

    That's an odd format, so I assume you mean 1 million to be displayed as:  1,000,000 ?
    http://help.sap.com/saphelp_xmii115/helpdata/en/Applet_Reference_Details/ParameterReference.htm#Number Formatting
    #,##0 should provide you with a comma as the thousands separator for all numbers in this column of your iGrid.

Maybe you are looking for

  • How do i sync Notes from Mac to iPhone?

    How do i sync the notes on the Notes app to an iPhone? I want the notes that i have on my Mac on the iPhone, not the other way around. I know its possible to sync iPhone notes with the Mac if you have ML, but i cant find a tutorial on how to do the o

  • Page headers are not exported to excel files - Is there a workaround?

    I use 2008, SP3. I am experiencing a problem with exporting to Excel(.xls): the page headers, but the very first, are not exported. The report page headers consist of weekdays and the corresponding dates, meanning they are different on each page. The

  • Secure mailbox

    Is there anyway that Mail 4.2 on OS X 10.6.3 can utilize a mailbox in a secured sparse bundle file system? This is what I would like to have: I use two imap accounts with various mailboxes within them, and I have a set of mailboxes on my Mac. I would

  • Looking for an AIR Native Extension for iOS that will allow / disable access to certain apps

    I am looking to find and or create an ANE that will allow access and or disable access to certain apps such as internet, text, games, vine etc.  This url represents the closest app to what I am trying to achieve:  https://itunes.apple.com/us/app/pare

  • Thursday is the last day to vote for your favorite authoring tool

    Hi, folks. Thursday, January 6 is the last day to vote for your favorite authoring tool! WritersUA is inviting help authors to participate in it's annual tool survey. http://www.surveymonkey.com/s/tools_survey It's not long, just a page. I'd encourag