Logic for this math problem

Before I get stinker replies for cross posting , let me tell that , i have been recommended to post this in this forum.
My problem is such:
I need to find a logic to implement the following :
In the floating point number , say , 1.0.. the Integral part will remain constant(1) but the decimal part has to get incremented by 1
1.1 +0.1
1.2+0.1
1.3+0.1
1.4+0.1
1.5 +0.1
1.6+0.1
1.7+0.1
1.8+0.1
1.9+0.1
1.10+0.1
1.2... But what I need here is 1.11 ,1.12
I need my programming logic to detect there needs to be a change in the increment value from 0.1 to 0.01 when I reach 1.1
and from 0.01 to 0.001 when i reach 1.111..so on,
please suggest..

you can't do it with a double,
since double d = 1.10d; will be treated as 1.1d
what you can do is treat the double as a String
public void test(){
String s1 = "1.9";
String s2 = "1.10";
String s3 = "1";
String s4 = "1.1";
System.out.println(increment(s1));
System.out.println(increment(s2));
System.out.println(increment(s3));
System.out.println(increment(s4));
public String increment(String d){
int pos = d.indexOf(".");
if (pos != -1){
if (d.charAt(d.length()-1) == 0)
return d.substring(0, d.length()-2) +
ength()-2) + "1";
String temp = d.substring(pos+1);
int num = Integer.parseInt(temp);
num++;
return d.substring(0, pos+1) + num;
else
return d + ".1";
}gives
1.10
1.11
1.1
1.2
I leave it to you to understand the logic...it's to
get you started..it does not check for all conditions
of the inputI think it is a Math with algorithm problem. Your solution is good, but you are using String functions so much. There is other solution, handling with numbers only.

Similar Messages

  • Logic for this comparision of character type operands.

    Source field name: ZDCNFG
    Target Info Objects:
    ZDVD59
    ZDVD10
    ZDVD14
    ZDVD18
    ZDVD25
    ZDVD50
    Scenario1: If ZDCNFG = 2(10). 2 is quantity and 10 in brackets is part number (DVD format). So I will have to update the quantity respective field as shown below.
    ZDVD59: 0
    ZDVD10: 2 -->updated 10 part
    ZDVD14: 0
    ZDVD18: 0
    ZDVD25: 0
    ZDVD50: 0
    Scenario2: If ZDCNFG: 2(25)3(50)
    ZDVD59: 0
    ZDVD10: 0
    ZDVD14: 0
    ZDVD18: 0
    ZDVD25: 2 --> Updated
    ZDVD50: 3 --> Updated
    Scenario3: If ZDCNFG: 2(5)3(9) ---This is exceptional case. If we have 5 and 9 then add and assign 5 to ZDVD59 rest all are 0.
    ZDVD59: 5  Sum of DVD5 and DVD9
    ZDVD10: 0
    ZDVD14: 0
    ZDVD18: 0
    ZDVD25: 0
    ZDVD50: 0
    Quantity is the value which is out side the brackets. For e.g. in 10(5), 10 is the quantity.
    Can any one give me a logic for this.
    I was trying with CA  CS etc..but no charm.
    Thanks
    Kiran

    Kiran,
    This should work
    parameters: zdcnfg(50).
    data: zdvd59(3),
    zdvd10(3),
    zdvd14(3),
    zdvd18(3),
    zdvd25(3),
    zdvd50(3),
    rcnt type i,
    roff type i,
    temp type i.
    data: static(50).
    start-of-selection.
      static = zdcnfg.
      replace all occurrences of '(5)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(5)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd59.
        enddo.
      endif.
      zdcnfg = static.
      clear: roff, rcnt, temp.
      replace all occurrences of '(9)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(9)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd59.
        enddo.
      endif.
        zdcnfg = static.
      clear: roff, rcnt, temp.
      replace all occurrences of '(10)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(10)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd10.
        enddo.
      endif.
        zdcnfg = static.
      clear: roff, rcnt, temp.
      replace all occurrences of '(14)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(14)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd14.
        enddo.
      endif.
        zdcnfg = static.
      clear: roff, rcnt, temp.
      replace all occurrences of '(18)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(18)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd18.
        enddo.
      endif.
        zdcnfg = static.
      clear: roff, rcnt, temp.
      replace all occurrences of '(25)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(25)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd25.
        enddo.
      endif.
        zdcnfg = static.
      clear: roff, rcnt, temp.
      replace all occurrences of '(50)' in zdcnfg with '+' replacement count rcnt.
      if rcnt ge 1.
        zdcnfg = static.
        do rcnt times.
          replace first occurrence of '(50)' in zdcnfg with '+' replacement offset roff.
          temp = roff - 1.
          add zdcnfg+temp(1) to zdvd50.
        enddo.
      endif.

  • Need the Logic for this Prg issue Pls

    Hi Friends,
    i have an urgent requirement..
    i am develop the report that is :
    Based on Selction Critirea kunnr(knvv-kunnr)
    i want Delete the
             Internet mail (SMTP) address FROM ADR6-MTP_ADDR
    AND Teletex number FROM ADR4-TTX_NUMBER..
    USING TABLES ARE KNVV , ADR6 AND ADR4.
    please how to Write the LOGIC For this Program .
    help me.. it is an urgent.. anyone.
    regards,

    Hi Alchermi,
    thanks for your reply soon.
    based on selction kunnr .. i want deete the ADR4-TTX_NUMBER..and ADR6-SMTP_ADDR From these 2 tables
    for these 2 fields..
    kunnr from knvv, selection field..
    below fields want be DELETED..
    ttx-number from adr4,
    smtp_addr from adr6.
    it is an urgent. help me .
    regards,

  • Logic for this senerio -- UDF

    Hi XI Gurus,
                          I hav to create a UDF.This is an IDOC - XI - FILE seerio. In  this senerio is I have an IDOc whose 7th segment contains a field. This field can store values in between 0 - 9. On the other hand I have a file structure in my left hand side from Messge mapping prespective , which contains 9 similar sized fields.
    Now the logic is if the field in the segment of the idoc has value say '3', then the file structure in the left hand side would have 3 in the field no 3 and all other fields 1, 2, 4, 5, 6, 7, 8, 9 would be zero.
    Can u guys suggest some logic for this???
    Thanks in advance !
    Poits would be rewarded.
    Arnab

    Hi Mohd,
    Select the Queue option for getting individual nodes
    public void test(String[] a,ResultList result,Container container){
    if (a<i> == 7) { //This is for selecting the node
    for(i=0;i<10;i++){  //This is for collecting the correct value
    ifIi==3){
    write what ever u have to done
    else{
    write the exceptional condition
    Dont to Reward points if this helps
    Regards
    Pragathi.

  • Pls i need help for this simple problem. i appreciate if somebody would share thier ideas..

    pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my  desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my  desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...

    If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.

  • Unable to find the published output for this request - problem

    Hi ,
    In the invoice Payables module i modified a report to be open in xml and not text as it was. The program name of this report iis Print Invoice Notice. I did same thing we normally do to register a xml report in ebs.
    The problem is that when i run the report from the invoice form and from the button wich call this raport i get this error:
    Unable to find the published output for this request.
    No output file exist for the request
    and if i see the log file i get this message :
    Arguments
    P_INVOICE_ID='10243'
    APPLLCSP Environment Variable set to :
    XML_REPORTS_XENVIRONMENT is :
    +/oracle/prodora/8.0.6/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb+
    XENVIRONMENT is set to  /oracle/prodora/8.0.6/guicommon6/tk60/admin/Tk2Motif_UTF8.rgb
    Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :
    AMERICAN_ALBANIA.UTF8
    +' '+
    REP-3000: Internal error starting Oracle Toolkit.
    Report Builder: Release 6.0.8.27.0 - Production on Fri Mar 27 02:30:46 2009
    +(c) Copyright 1999 Oracle Corporation. All rights reserved.+
    The thing is that if i run this report from Other ->Request -> Run of the same module this raport runs correctly
    And if i change the output of my report (From concurrent manager) to text its open correctly even from there where i want to open it.
    Can anyone give me any sugestion why i get this error while i try to open this xml publisher report from a button in a form in application?
    PS: i am using ebs 11.5 version
    Thanks in advance,
    Best regards

    Hi,
    REP-3000: Internal error starting Oracle ToolkitThis errors was discussed many times before in this thread, so please search for REP-3000 and fix this error first ( [REP-3000|http://forums.oracle.com/forums/search.jspa?threadID=&q=REP-3000&objID=c84&dateRange=all&userID=&numResults=15] )
    Regards,
    Hussein

  • Can anyone please give me the logic for this....

    I have a database table and in it i have a field department code. now, that department code might have '00' or '   ' (blank) or anyother value. now i want to add up all the currency amounts with department code '00'  and '  ' (blank) which have same company code and currency type. I called all the entries with '00' into one internal table and enrties with '  ' (blank) to other internal table.
    can anyone give me the logic for adding all the entries at a time.
    thanks in advance.....

    HI Srinivas
    i have a solution for this question.
    Use At control break statement for this.
    Loop the internal table.
    Use at Event AT LAST. In that use SUM Statement. U will get sum of all the numeric fields.
    Or else u can use ON CHANGE OF Currency type
    then find the total amount by adding previouse value with ur current value.
    Like itab1-amount = total + itab1-amount.
    Appent this into ur internal or write it into ur report.
    Reward me if its useful.
    Regards
    Ravi

  • I installed OS X 9.0 and I get the beach ball all the time.Any fix for this? problem?

    I installed the new operating system OS X 9.0 and my performance degenerated. Spenning beachball, freezing up, slow for everything. Any fix for this problem?
    I have a Mack Book late 2009

    2gb is the stated bare minimum to run the OS, anything you try to run after that is going to cause exactly what you're complaining about. Your MacBook can use up to 8gb and I believe you'd be wise to upgrade.
    http://www.everymac.com/systems/apple/macbook/specs/macbook-core-2-duo-2.26-whit e-13-polycarbonate-unibody-late-2009-specs.html
    Crucial is an excellent source http://www.crucial.com
    As is OWC http://eshop.macsales.com
    I would avoid the bargain basement brands and be sure to get exactly the right ram or you'll have problems.

  • Using QuB for this database problem

    Hi, I have a problem of trying to list links on a website I am creating and if I am correct, I need to link 2 tables on the database. I was trying to use QuB for this but am tearing my hair out.
    Here is my problem:
    I have a list of links on a website and each one belongs to a category for eg:
    Category: Biomass
    Comapny Name: AN Other
    WebLink: http:abc.com
    Now how can I show all the Biomass links together under the one heading and all the others under their own heading eg, Windpower, Boilers etc.
    Can I use QuB for this?
    The tables I have are:
    Table 1:
    id
    Category
    Table 2:
    id
    Category
    Client
    Weblink
    That's it, hope I haven;t confused everyone, because I'm confused enough!
    Thanks in advance.

    Unfortunately, this is a common problem with serialization : If an obj which does not implement Serializable is a non-transient member of an object that is Serialized, Java throws a NotSerializableException.
    Therefore, you have to walk through the chain of objs to make each one of them serializable, which is not always practical.
    Below is a link that presents a solution to this problem, by using a SerializableAdapter (using the Adapter design pattern) :
    http://www.javageeks.com/Papers/SerializableAdapter/SerializableAdapter.html

  • Is there any alternative logic for this issue

    Hello all ,
    I have a  program which is executed as a background job for every 15 minutes . Now my requirement is If this batch job is successfully finished, i have to capture that time and date at which the batch job is successfully finished and update the corresponding time and date in a ZTABLE .
    In order to achieve this , i have created a separate program which will also be running in background.in this program , using the table TBTCO, i m getting the last date and  last time at which the batch job is successfully finished and modifying the ZTABLE accordingly
    Is there any alternate solution for this ?
    thanks&regards,
    G.Pavan

    Hi gpavansap,
    When you define background job in SM36, your first step should be the program which you have scheduled now.
    Create a second step in the same job with another program which would just update system date and time to the ZTABLE. No need to read TBTCO and all.
    The second step would immediately execute as soon as the first step ended successfully.
    If you don't want to create a separate program. you can have a check-box "Update ZTable Only" in the selection screen of the first program itself. If this check-box is selected, the program should only update ZTABLE and do nothing else. Create a variant of your selection screen with this check-box selected and schedule this variant as "Second Step" of your back-ground job.
    Regards
    Suresh

  • Process chain Logic for this scenario

    HI,
      We have a typical requirement that need to be implemented using a Process chain.
    We need to Load data from R/3 to PSA,
    then Load the data from the PSA into ODS1,
    then execute an ABAP program,
    then load the data from PSA into ODS2 (we cannot repull from R/3).
    Can some one provide me an Idea on how to implement this.  I am stuck with the idea on how to populate ODS2 from PSA after executing ABAP Program.
    Thanks In advance,

    Hi Krishnamohan,
    I hope i m getting ur problem right.I think u can implement the below steps easily :
    Step 1 : We need to Load data from R/3 to PSA,
    Step 2 : then Load the data from the PSA into ODS1,
    Step 3 : then execute an ABAP program,
    U have options avaialable for each of them in process chains.
    Now coming to your problem.
    Step 4 : then load the data from PSA into ODS2 (we cannot repull from R/3).
    i guess ur Abap program makes some changes in the Data of PSA which u then want to load in the ODS2.
    What u can do is create 2 infopackages and inside infopackages in the data targets tab select ODS1 in the first infopackage and uncheck ODS2 , likewise in the 2nd infopackage select ODS2 and  uncheck ODS1.
    U can execute the first infopackage in the process chain , then ur abap program and then
    In process chain and in Process types u have something called "Read PSA Data and Updata Data Target".
    select that process type , specify the 2nd infopackage name and get it executed.
    Hope it helps.
    Thanks and Regards,
    Parth.

  • Help on Logic for this kind of XML structure ^__^

    Hi
    I just started studying XML parsing and Im currently using SAX to parse XML docs... I know how to map info on a simple class file but this structure is much more complex for me heheh...
    ok, suppose I have an xml whose structure is like this:
    <PO_SUMMARY>
        <Store_PO>
                  <POheader>
                          <a>ABC</a>
                          <b>123</b>
                  </POheader>
                 <POLINE>
                           <c>456</c>
                           <d>789</d>
                 </POLINE>
                 <POLINE>
                           <c>125</c>
                           <d>525</d>
                 </POLINE>
        </Store_PO >
       <Store_PO>
                  <POheader>
                          <a>GHS</a>
                          <b>321</b>
                  </POheader>
                 <POLINE>
                           <c>525</c>
                           <d>646</d>
                 </POLINE>
                 <POLINE>
                           <c>636</c>
                           <d>242</d>
                 </POLINE>
        </Store_PO >
    </PO_SUMMARY>My problem is how can I generate separate txt files, each containing the details of the first <Store_PO> and second <Store_PO>???
    Hoping for your suggestions!!! THANK YOU VERY MUCH for your time!!

    The output should be separated text files that look like this
    For the first StorePO
    HDR 123 ABC
    DTL 456 789
    DTL 525 646
    For the second StorePO
    HDR 321 GHS
    DTL 525 646
    DTL 636 242
    I have two objects to map the contents of header and poline
    I can get the contents of that xml IF it's StorePo is only ONE.. what do you suggest I should do??

  • Any fix in sight for this Aiport problem, Apple? Please?

    My imac had been useless for about two months now. macbook and powerbook working perfectly off same Base Station. As a longtime Apple owner 3 PBs, 2 macbooks, 2 imacs, countless ipods - this seems very unlike Apple. I don't get it. The firmware worked perfectly before! Why not just revert? Finding this very frustrating that it hasnt been addressed. Hope they get it right soon!

    Why not just revert?
    Because this is not a general problem. There is a specific problem on your iMac. Waiting for a fix that Apple is not working on would be a long wait. Wireless is certainly working fine on my Intel iMac.
    The problem could be software or hardware. You'll have to provide more details. What model is your iMac? What happens when you attempt to connect to your wireless network? Does your network or any other close-by networks appear in the list of available networks? Do you get any obvious error message, or does it seem to connect but just does not work? If it seems to connect but Internet does not work, are you able to do other network things, such as file sharing with one of your other Macs? Do you get a network connection that works properly if you connect the iMac to the base station using an Ethernet cable? Those are the types of details that will help in trouble-shooting why it doesn't work for you, while it is working fine for others.
    The best way to distinguish between a hardware problem and a software problem is with an external drive. If you have an external FireWire or USB 2.0 drive, even a small capacity old drive that you no longer use regularly, connect it to the iMac, and install Leopard on it using the +Erase and Install+ option. This will obviously erase your drive, so don't use a drive with important data. Restart from the drive and bring it up-to-date by running Software Update a few times.
    Does wireless work? If it does, there is some software issue in your regular installation. If it does not, there is a pretty good possibility that the problem is hardware-related.

  • IPod Touch stopped working after i upgraded it from iOS4.3.3 to iOS6. Now even if i restart my iPod it shows a iTunes symbol followed by a upward arrow mark and a USB symbol. I cannot find any solution for this particular problem in Help section.

    I tried to upgrade my iPod from iOS 4.3.3 to iOS 6 through iTunes. As soon as it completed the download of the 840 MB file, it said that my iPod is being restored. But after a considerable amount of time it said my iPod could not be restored and stopped. Now my iPod screen is just displaying a iTunes symbol followed by an upward arrow mark and then a USB symbol.
    iTunes has stopped to detect my iPod anymore. I tried to update iTunes 10.7 as requested in the website support page. But if I check for updates in iTunes it is detecting the available updates but not updating it when i click on the update button.

    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar

  • Can anyone please help me with the logic for this..

    hi all,
    os  has the value Windows 2000
    IF os CP 'WINDOWS' OR os CP 'SUN'.
         OS1 = 'X'.
      ENDIF.
    (if i test this,
    os1 doesnot have any value, (should be x)).
    This doesnot work for me.
    Any suggestions.
    Regards,
    Sukumar.

    Dear Sukumar,
    just use the F1 help on CP in ABAP code, there is a description.
    I think you need to use the asterix '*' than it will work.
    Regards
    Tibor
    Just check the example:
    Report z_example.
    data: os1, os type string.
    os = 'WINDOWS 2000'.
    IF os CP 'WINDOWS' OR os CP 'SUN' or os = space.
    OS1 = 'X'.
    ENDIF.
    write: / os1.

Maybe you are looking for