Counter not incrementing

Here is the code from one of my classes, these methods are used when a button is cliked in another class.
My problem is that the counter for rate is not incrementing for some reason.
Can anyone see a reason from the code why?
public class AccountModel
    private Account c, d;
    private int counter=0;
    public AccountModel()
        c = new Account();
        d = new Account();
    public AccountModel(String Name1, int intialAge1, String Name2, int intialAge2)
        c = new Account();
        c.setName(Name1);
        c.setInitialAge(intialAge1);
        d = new Account();
        c.setName(Name2);
        c.setInitialAge(intialAge2);
    public void saveData(int option, String newName, double newDeposit, int newInitialAge,
                         double newRate)
            if (option==1)
                setData(c,newName,newDeposit,newInitialAge,newRate);
            else if (option==2)
                setData(d,newName,newDeposit,newInitialAge,newRate);
    public void setData(Account a, String name, double deposit, int initialAge, double rate)
                a.setName(name);
                a.setDeposit(deposit);
                a.setInitialAge(initialAge);
                a.setRate(rate);
    public String showData(int option)
        String display = "";  //display string to return
        Account acc;    //local account variable
        if(option==1)   acc=c;  //choose which account
        else acc=d;
        //build string
        display += "Name: " + acc.getName() + "\n";
        display += "Initial Age: " + acc.getInitialAge() + "\n";
        display += "Actual Age: " + acc.getActualAge() + "\n";
        display += "Total Balance: " + acc.getBalance() + "\n";
        display += "Total Deposit: " + acc.getTotalDeposit() + "\n";
        display += "Total Interest: " + acc.getTotalInterest() + "\n";
        display += "Total Withdrawals: " + acc.getTotalWithdrawal() + "\n";
        display += "Interest Rate: " + acc.getRate() + "\n";
        return display;
    public double getBalance(int option)
        Account acc;
        if(option==1) acc=c;
        else acc=d;
        double balance = acc.getBalance();
        double deposit = acc.getDeposit();
        double rate = acc.getRate();
        for (int i = 0; i < acc.getYears(); i++)
            balance = (balance + deposit*12) * (1 + rate/100);
            if (counter % 10==0)
                rate = rate + 0.01;
            counter++;
        acc.setBalance(balance);
        return balance;
    public double keepDepositing(int option, int continuedYears)
        Account acc;
        if(option==1) acc=c;
        else acc=d;
        double balance = acc.getBalance();
        double deposit = acc.getDeposit();
        double rate = acc.getRate();
        for (int i = 0; i < continuedYears; i++)
                balance = (balance + deposit*12) * (1 + rate/100);
                if (counter % 10==0)
                    rate = rate + 0.01;
                counter++;
        acc.setBalance(balance);
        return balance;
    public double startWithdrawing(int option, double withdrawals, int withdrawalYears)
        counter=0;
        Account acc;
        if(option==1) acc=c;
        else acc=d;
        double balance = acc.getBalance();
        double rate = acc.getRate();
        for (int i = 0; i < withdrawalYears; i++)
                balance = (balance - withdrawals*12)*(1 + rate/100);
        acc.setBalance(balance);
        return balance;
        }

rate is a local variable in all your class methods. When you leave the method the value goes out of scope.
You don't post your Account class, so I can't tell if it has a rate data member.
If you want it to persist after you've left those methods, make it a data member in the AccountModel class.

Similar Messages

  • Answer Count not incrementing

    Hi,
    I've noticed since your revised website that the Top Enthusiats in TestStand Answers' count doesnt increment any more.
    Regard
    Ray Farmer
    Regards
    Ray Farmer

    Hi Ray,
    We are investigating this issue, and this is on the list for getting fixed. Thanks for letting us know! I'll update this thread when more information is available.
    Thanks,
    Wilbur Shen
    National Instruments

  • ACE show serverfarm - failure counter does not incremented on Probe-Failure event

    Hi,
    Despite of probe-failure the failure counter is not incremented. Is there any correlation between the configured probe and the failure counter?
    (Custom script probe is used for this serverfarm)
    # sh serverfarm xxxxxSt
    serverfarm     : xxxxxSt, type: HOST
    total rservers : 2
                                                    ----------connections-----------
           real                  weight state        current    total      failures
       ---+---------------------+------+------------+----------+----------+---------
       rserver: xxxxx6
           10.222.0.90:8000      8      OPERATIONAL  13         157        0
       rserver: xxxxx7
           10.222.0.92:8000      8      PROBE-FAILED 0          0          0
    Thanks,
    Attila

    Hi Attila,
    The Connection Failure counter under show serverfarm is for Loadbalanced Connections which are failing.
    If Probes are failing, this counter will not increment.
    The Connection failure counter can increment for various reasons some of them are,
    - Server not responding to the SYN packet sent by ACE for Loadbalanced connection
    - Server sending Reset to the SYN packet sent by ACE for Loadbalanced connection
    To check on stats for Probe, you can run "show probe detail" command.
    Hope this helps,
    Best Regards,
    Rahul

  • 11.0.2 does not increment play count

    I have smart playlists that are based on play count.  Sometimes as iTunes plays the count increments and sometimes it doesn't.  When it does, it replaces the tune it was just playing insteads of adding a new tune to the bottom of the list.  When it doesn't iTunes moves down the list.  Eventually it gets to the bottom and stops.  If the count criteria is < 1, it should increment the count, remove the tune from the list and add another at the bottom but it doesn't.
    I have cross-fade turned off.  I understand this used to be a problem that was fixed.  However, I left it off anyhow.
    What else do I need to check/correct/do?

    I made some screen shots to demonstrate.  First is the initial list when I started to play it followed by the list when the last track had completed.  This demonstates how some tracks get their count incremented and are replaced while others do not.
    BTW, it does appear that the list is updated in place rather than at the end.  I was looking for a list that would never stop playing but I guess that is impossible.  No matter, I can make it long enough to work but I can't figure out why sometimes the count gets incremented and sometimes it doesn't

  • [Forum] user clicks on thread, counter is incremented - again, again..

    The following is definitely a minor problem, but you might want to change it in the board's software: say I just visited a thread, return to the forum and click on the thread again. The counter will increment, even if the time in between was only a few seconds.
    The same happens, if I create a topic and click on it several times.
    Maybe there should be some time in between? Say, the counter is reactivated after the session of the user on the server ends and a new session is created when he comes back...?
    No big deal of course, but this could be confusing....

    Yeah, once he said views-counter it kinda clicked in my mind.  On one hand, it's reasonable to say "If somebody looks at this thread, then looks at it again 1 minute later, that's not two separate views".  However, on the other hand, I wonder how many people sit on one thread reloading it over and over.  I know I use the "show new posts since last visit" functionality to keep track of that for me, and if there's a thread I really want to watch, I subscribe to it.

  • Generic Error count singnificant increment

    Hi ,
    What are the reasons for the Generic Error count to increment singificantly .  do we need to concern on these counters .
    *               Plim-asic ASIC Error Summary               *
    Instance              : 0
    Number of nodes       : 5
    SBE error count       : 0
    MBE error count       : 0
    Parity error count    : 0
    CRC error count       : 0
    Generic error count   : 37828019
    Reset error count     : 0
    Instance              : 1
    Number of nodes       : 5
    SBE error count       : 0
    MBE error count       : 0
    Parity error count    : 0
    CRC error count       : 0
    Generic error count   : 4001807772
    Reset error count     : 0
    Thanks & Regards,
    Gobinath.

    Hello,
    GENERIC Errors — Errors that do not fall under any of the other classifications.
    Threshold and alarm reporting is done.
    I think it shall be good if we take some action upon this
    Regards
    Thanveer
    Please rate if the post is helpful

  • 3550-12T ACL OUT counters not incrementing.

    We have several acl’s applied against various vlans on the 3550-12T switch IOS version c3550-i5q3l2-mz.121-22.EA1a.bin. Noticed that if the ACL is applied IN on the interface that all hits are counted. It appears that only the denies are being counted on an ACL if it is applied OUT on the interface.
    I am using the permit any any established command and would have expected to see massive counts on this line. When compared to the behavior on the 4507 ACL the established counter increments dramatically.
    With out the hit counts it is hard to see what is being done and if an ACL entry is even required.
    Any suggestions?

    ACLs counters will not increment if the traffic is switched via hardware. The ACL counter will only be incrementing on software switched traffic, with matching ACL entries.

  • Playcounts not incrementing?

    I subscribe to several podcasts, audio, video, and mixed, but none of them seem to be incrementing the playcounts when I listen to them anymore. Some of them even still show the 'unplayed' blue dot on the iPod immediately after they finish.
    This is more than just annoying, because I have my podcasts set to only keep unplayed episodes, and I am having to manually delete them to free up space.
    I'm not sure if the playcounts on audio files are working correctly, I should know by the end of the day, though.
    I sync my iPod (w/video) with an iMac G5, my library is on a firewire drive...
    Has anyone else had a simmilar problem? Was there a fix, other than wiping the iPod & starting over? Or is this a 'take it to the apple store' problem?
    Thanks!

    Is your iPod set to automatically sync when you connect it to your Mac or are you using manual sync? My understanding is the latter, manual sync, does not increment play counts. For that you need to auto sync or try a third party script to help fix that.
    Patrick

  • Time Machine making full backups--not incremental

    Hi,
    I just installed Snow Leopard on my Mac Pro a couple of days ago, and have been using Time Machine to make backups (never used it before now). I have TimeMachineEditor installed, and have it set to make a backup daily at 3:30am. It backs up data from my 500GB main hard drive to another internal 500GB hard drive.
    The first backup went without a hitch, and did a full backup as expected (everything). But the second, third, and fourth backups all were full backups as well....not incremental as they should've been. The fourth one was actually a manual backup I did to test it...I chose "Back Up Now" to see if it did full or incremental. It did a full backup.
    So, after four backups, each a little over 100GB, I'm already running out of space Has anyone else run into this behaviour? Is this a consequence of TimeMachineEditor having screwed it up somehow? Even if it has, shouldn't a manual backup still do an incremental backup?
    Very strange....

    canadavenyc wrote:
    V.K. wrote:
    yes, well, if Toronto ever gets a team in any sport worth rooting for, I might stop posting on apple forums and start watching them.
    lol...well, seeing as how you'll clearly be here a while then... ...perhaps I can prevail upon you to answer one last question that just occurred to me.
    Let's say I have tons of TM snapshots on my backup drive, and at some point I want to delete a few to clear some space. I know TM automatically goes after the earliest ones when the drive fills up,
    You should know that TM also constantly thins recent backups. It keeps hourly backups for 24 hours and then deletes all but one for every day; it keeps daily backups for 30 days and then deletes all but one for every week. it keeps all weekly backups till the TM drive gets full at which point it starts deleting the oldest ones.
    but let's say I manually want to delete a few snapshots that contain, say, a massive cache file or something totally useless to keep around, which I could afford to delete and would gain me a lot more drive space.
    When I go into the TM interface to do the removal, how can I figure out which snapshots to get rid of? How would you do it?
    TM offers two options. you can delete an entire backup corresponding to a time point or it can delete all backups of a given file/folder. to do that enter TM and scroll back in time to some time point. select something and click on the "gears" action button in Finder toolbar. you'll see options "delete backup" (deletes the entire backup for that time point), and 'delete all backups of this item". deletes all backups of the selected item from all time points. I use the latter sometimes to get rid of backups of very large files.

  • Count(*) returns 'Column 'Count' not found' SQLException

    I am trying to get the count from a table using the following:
    String query = "SELECT COUNT(*) FROM myTable;"
    I know that the connection is open and working because I am getting back an SQLException:
    'Column 'Count' not found' .
    The same command works fine at the command line. I would be grateful for any suggestions as to why JDBC sends my app searching for a field named count in my table whereas the command line returns the expected number.
    Thanks.

    Found the problem, which is mainly my own stupidity . Is it one of Murphy's laws that the quickest way to find the solution to a problem if first embarrass yourself by asking foolish questions? Sorry to have bothered anyone.

  • How do you create a counter/or increment a number in SQL Developer?

    How do you create a counter/or increment a number in SQL Developer?
    for example:
    x = x + 1; // add 1 to the value of x
    Thanks,

    Thank you for your help. In reply to your comment I notice that I forgot the colon ":" when I "DECLARE x = 0;"
    When I fixed the "DECALARE x := 0;" the code works fine. See below:
    SET SERVEROUTPUT ON
    Declare
    x integer :=0;
    BEGIN
    -- use a FOR loop to process a series of numbers
    FOR i in 1..3 LOOP
    x := x + 5; ---// add 1 to the value of x
    DBMS_OUTPUT.PUT_LINE('Counter: ' || TO_CHAR(x) || ' Square: ' || TO_CHAR(i*i));
    END LOOP;
    END;
    ---------------- OutPut ----
    anonymous block completed
    Counter: 5 Square: 1
    Counter: 10 Square: 4
    Counter: 15 Square: 9
    ====================================
    Thank you again and greatly appreciate your feedback.
    Have a great day!!

  • PS Batch/Droplet serial number not incrementing?

    Hello
    I'm hoping someone can provide a solution.
    I'm trying to make a batch that ill then convert to a droplet so I can then use a watch folder to run the droplet. (Automate as much as possible, as I process a lot of files)
    A little how I would process files at present: Open mockup in PS>run batch with action already created, once complete, move onto the next mockup.
    Now the master mockup file I use has a smart layer that I place data into, this then transforms the pasted image into a mockup to represent the product.
    Now the problem, the serial number does not increment as I'm trying to use a droplet I have to include an open and close command for the mockup, this then stops the number incrementing. (The number must be attached to the PS file). This then keeps exporting the files and over riding 001 every time.
    We use extend script with illustrator daily so I'm not sure if using this is a solution?
    Any feedback is highly appreciated!
    Thanks!

    Try using the Image  Processor Pro in the action you used to create the droplet.   If the output file exist that script will generate the next name. Actions can not use logic on their own.  If the droplet you create has a problem naming the output file that it replaces files rather then generating the next name the action you created the droplet  needs to use some scripting. See that the output file exists and if it does generate a unique name upping the sequence number till  its unique one that does not exists.  Actions can not use logic without using a script.
    The Image Processor script is not a plug-ij it will always show its dialog.  The Image Processor Pro script is a Photoshop Plug-in It will bypass displaying iys dialog when user by playing the action step that was generated recording its used.  What it recorded will be used.    Once installed the Image Processor Pro script is accessec and recorded usinf  menu File>Automate>Image Processor Pro...   Where the non plug-in Image Processor the ships with Photoshop is Access via menu File>Scripts>Image Processor.  It does not have plug-in support programmed in. It can not record settings into an actions step.
    When you record the IPP action the dialog will show and IPP will record the settings used into the action step,  When the action is played the dialog will not show instead the recorded setting will be use.  If you do not turn on that action step dialog.
    There is no requirement to use the bridge.... Infact if you use the bridge to select files then use menu tools Photoshop Image processor Pro  you will not be using  your droplet or action..  If you set up the IPP dialog to use your action that uses IPP I think it may fail recursive use of a plug-in is questionable.

  • Inside program prmary key is not incremented beyond 10

    hi all,
    I made use of SNRO transaction to create an object and in my program I used the function "Number_get_next"  to increment my primary key.
    I donot know what happened in the object , but inside my program the number only incremented upto 10 and again starts from 0.
    But inside object i checked the current no and it shows the updated no.but in my program it not incremented.
    please help
    thanks,
    simadri

    hi miguel,
    Actually in my table the primary key is of CHAR data type and inside SNRO object I make use of NUM10 data type in the number length domain. Whether I have to change in the SNRO object or the domain of the primary key..??
    please suggest me what to do.. and which data type to use for more than 2000 records.
    thanks for your interest in my doubt..
    sekhar

  • LLQ policy counters not incrementing

    I have created a LLQ policy on a 1721 running 12.2(4)YH2 but the counters do not incrementing. I disabled fast-swithcing and the counters increment. Is this correct and is LLQ being used even though the counters do not show the packets being matched? I have a 3620 running CEF and the LLQ counters do increment, the 1721 does not support CEF (I am running IP only, not sure whether I need IP Plus to use CEF. Any thoughts?

    The Cisco IOS image which you are using, doesnt have the CEF Feature support on it. For a Cisco 1721, the IOS recommended for the features relating to CEF are:
    12.2(13)T or 12.2(13)T1. Following CEF Features are available in it:
    * CEF on Multipoint GRE Tunnels
    * CEF/dCEF - Cisco Express Forwarding
    * CEFv6/dCEFv6 - Cisco Express Forwarding
    So, an IOS upgrade to your router should help you solve the problem. You can verify the above recommened versions from the Software Advisor as given in the url below:
    http://www.cisco.com/cgi-bin/Support/CompNav/CN1.pl?HMajorRelease=&HFeatSelected=1211%7C315%7C1303&HReleaseNumber=All&HReleaseId=-1&HPlatformFamilyName=1721&HPlatformFamilyId=103&HFeatureSetName=NS&HFeatureSetId=0&HRN_Given=1&HPF_Given=0&HFS_Given=0&HReSelect=False&HVA_Lnk=False&HS12_But=&HS13_But=&HS2_But=&HDDMPlatFamDet=103&HPF_But=&HDDMRelDet=-1&HRN_But=&HDDMFeatSetDet=97&HFS_But=Update
    I hope, this will help you.
    Thanks.

  • Purchase count not completed

    my problem is when i buy something in game ( tower of saviors chinese version) it show me up "your purchase count not completed"
    please help me check it .THANKS

    Do you have in app purchases enabled in settings general/restrictions?

Maybe you are looking for

  • How to go from 14.0.7015.1000 to 14.0.7102.5004?

    Related to http://social.technet.microsoft.com/Forums/sharepoint/en-US/2ce0770e-dbb8-47db-b6b1-6a58729732bf/hotfix-kb2817527-the-expected-version-of-the-product-was-not-found-on-the-system?forum=sharepointadminprevious I've since installed SP2 (oserv

  • Notification settings "Do not notify me" not worki...

    I want to hide a group chat, but i don't want to remove it. I clicked "Hide conversation" on group chat and also in Notification Settings selected "Do not notify me", but it doesn't block notifications - I'm still getting notifications, whenever some

  • Kodo 3.1.2 + IBM  DB2 7.2 = No Suitable Driver?

    Hello there, we are trying to use Kodo 3.1.2 with DB 7.2 Fixpak 5 and higher. I've build an ant-script with the following snippet: <target name="defineSchemaKodo" if="jdo.implementierung.kodo"> <taskdef name="mappingtool" classname="kodo.jdbc.ant.Map

  • JDeveloper and ADF 11g Release 2(11.1.2.0.x) compatible WebCenter Version

    We are looking to upgrade ADF to 11.1.2.0 and looking for WebCenter compatibility. Could you please let me know WebCenter compatible version for JDeveloper and ADF 11g Release 2 (11.1.2.0.x) ? Thanks JP

  • Associating other extensions with text PDF Maker

    Is there any plan to allow users to associate other file extensions with a PDF Maker that are plain text?  We have proprietary files with extensions bom,bot,dbk,drd, dts,emn,ewprj and more that are essentially text files that can be opened with Notep