How can I put a limit on how many times my 'if' statement runs through?

          while (done == false)
               testnumber++;               //Testing the next number
               testdivisor = 1;          //Resetting the testdivisor
               System.out.println("1st while statement");
               if (testdivisor <= testnumber)
                    testdivisor++;
                    divisors = testdivisor % testnumber;
                    System.out.println("2nd while statement");
                    if  (divisors == 0)
                         divisor1= testdivisor/testnumber;
                         System.out.print (divisor1);
                         System.out.println("3rd while statement");I need to stop it after it goes through the 4th if statement 4 times. The specific code might not make sense because it's a rough copy, but it will give you an idea of the program real quick.
So is there any way to make it stop after 4 runs through the last if statement?

So is there any way to make it stop after 4 runs
through the last if statement?If you seriously can't think of how to do that, are you sure programming is up your alley?
int hits = 0;
while (!done) {
  if (divisors == 0) {
    ++hits;
    ... // do your current stuff
    if (hits >= 4) break;

Similar Messages

  • How can i put the value of a variable in an SQL statement?

    Hi,
    Can someone please tell me how i can use a variable as part of an sql statement.
    So instead of "SELECT * FROM tablename WHERE username='john'"
    I can put in "SELECT * FROM tablename WHERE username.text"

    What would happen if someone entered "(delete *
    from tablename)" into the username field?The SELECT would fail and the DELETE
    would never run.
    Or am I missing something?Ok, that wasn't valid SQL, so lets change it into valid SQL. What would this do
    "SELECT * FROM tablename WHERE username=" + user
    where user is "blah;DROP TABLE tablename;"
    The SQL would become
    SELECT * FROM tablename WHERE username=blah;DROP TABLE tablename;
    And that would select, and then drop the table
    Kaj
    Message was edited by:
    kajbj

  • How can I put video stream on flash media server on to website running on IIS7?

    We are encoding live video feed using Flash Live Media Encoder and publishing it using Flash Media Server. Is there any documentation on how I can put this publishing point on a website running on IIS7?

    Sorry - but not very clear what you are trying to achieve here - can you please elaborate what you want to do?

  • I moved folder Itunes folder to the desktop.if I open Itnues now, I cannot see my library.how can I put it back in the folder "music" in Finder?

    I moved folder Itunes folder to the desktop.if I open Itnues now, I cannot see my library.how can I put it back in the folder "music" in Finder?

    done through Hard Disk at top right of the screen...itnues folder is there already because of my dragging into folder/music..but Itunes does not ope the whole library.
    whn I opened it, itwas like it had never been on the mac and it downloaded my last purchasesdone with the iphone...now it only shows that one album purchase

  • Hello! how can i put and read my words documents in the notes pad of my ipod nano 3trd generation?thanks to all.the notes

    hello! how can i put and read my words documents in the notes pad of my ipod nano 3trd generation?thanks to all.

    The Notes features of the 3G iPod Nano only supports TXT files and not Word Documents.  If you want to be able to read these word documents, you'll need to copy the text from each over to a text file.  See here for more information.
    iPod: Storing and reading notes
    Keep in mind that each txt file has a limit of 4096 characters.  See this article for more information as well.
    Long notes are truncated on your iPod
    B-rock

  • How can i put apps from one ipod to a new ipod?

    how can i put apps from one ipod to a new ipod?

    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device

  • How can I put my icloud photos to camera roll or photo stream?

    I got a nee iphone, i backed up everything and restored it into mu new iphone, but the pictures didn't restore so i did it manually but now on my phone i got different albums icloud photo stream and camera roll. How can i put the icloud picture into camera roll or photo stream. Any ideas?? On my old iphone ive deleted everything.

    Hello Ozzie94,
    Thanks for the additional information. The camera roll is designed for photos taken on your device, or saved images from Mail and other applications. Photos synced from a computer are organized into their own album(s):
    View photos and videos - iPhone
    http://help.apple.com/iphone/7/#/iph3d267610
    - Camera Roll—photos and videos you took on iPhone, or saved from an email, text message, webpage, or screenshot
    - Shared photos and videos—Photos and videos that you’ve shared with iCloud Photo Sharing or that others have shared with you (see iCloud Photo Sharing)
    - Photos and videos synced from your computer (see Sync with iTunes)
    Additionally, you may find more information by using another one of Apple's support resources - https://getsupport.apple.com
    Thanks,
    Matt M.

  • How can I put my podcasts in one place and my music in another?

    How can I put my playlists on my NAS media server (Buffalo Linkstation mini) so I can access them through Home Sharing and Sonos?  FYI, right now I run my iTunes with media location on my laptop's c: drive so I can manage podcasts while on the go and map a lettered network drive to the media server device when I connect up at home.

    Duplicated: https://support.mozilla.com/en-US/questions/886179

  • How can i put my itunes library from an old mac g4 10.4.11 to an ipod2?

    How can i put my itunes library from an old mac g4 10.4.11 to an ipod2?

    Install iTunes 9.2.1 on your computer. If the device's requirements specify iTunes 10 or newer, you need to purchase Mac OS X 10.5 on DVD.
    (63879)

  • How can i put photos from my mac to my ipad touch

    How can i put photos from my mac to my ipad touch
    I have them in an album.
    Thanks for your help

    See:
    iOS and iPod: Syncing photos using iTunes

  • On Firefox 4, how can I put one "new tab" on the "tab bar" (The + sign) and one next to the "back/forward" buttons (as in FF 3.6)?

    On Firefox 4, how can I put one "new tab" on the "tab bar" (The + sign) and one next to the "back/forward" buttons (as in FF 3.6)?
    In my current Firefox, the "new tab" icon/item from the "customize" pop-up window menu of items is placed next to my home, back, forward buttons near the top-left of my header (Button 1 for "new tab"). Then, the tab bar automatically come with a small tab (with a + sign) to the right of your last tab opened (so you click on + and a new tab opens. Button 2 for "new tab"). I like to have this "new tab" button twice (as a + mini tab, and next to my "home icon".
    When I upgraded to Firefox 4, I seemed to be only able to "customize" or use the "new tab" in one place. Either as an icon next to home button, or as a "+ minitab", but NOT both.
    What can I do to put this button in Firefox 4 on BOTH places???
    Your help is really appreciated. I want to upgrade, but I want my buttons on both places...
    I upgraded to FF 4, but downgraded again just because this feature... that's just me of coarse :-)

    *New tab toolbar button: https://addons.mozilla.org/firefox/addon/new-tab-toolbar-button/

  • How can I put a .pdf (or table) in iWeb that one sees on the web site on a web page without downloading?

    How can I put a pdf (not downloadable, but viewed on the website) or a table in iWeb?

    If it's a one page PDF file just drag it onto the webpage and resize to fit. If it's a multi page PDF file you can add it as in this demo page: Scrolling Text Box
    OT

  • How can I put my recently purchased iTunes movies on to my thumb drive and WD My Passport external hard drive. My Mac keeps saying "can't be copy because it is too large for the volumes format

    How can I put my recently purchased iTunes movies onto my thumb drive and WD my passport external hard drive.My Mac is saying that can't be copied because it is too large for volumes format

    [file] is too large for the volumes format
    That is usually an indication that the Volume was never Erased or Partitioned for GUID partition table and Mac OS, and is still in a Windows format.
    Mac OS X Extended (journaled) has no such file-size limitations

  • I have ringtones on itunes how can I put them on my iphone 4

    I have ringtones on itunes how can I put them on my iphone

    It has always been very basic to always maintain a backup copy of your computer for just such an occasion.  Use your backup copy to put everything back.
    If for some strange reason you have failed to backup ( not good at all), then you can transfer itunes purchases from an ipod:  File>Transfer Purchases

  • I have three different listings for Bob Seger on my iPod (bob Seger, Bob Seger System and Bob Seger and The Silver Bullet Band) How can I put all 3 in the same artist folder without changing artist name?

    I have three different listings for Bob Seger on my iPod (Bob Seger, Bob Seger System and Bob Seger and The Silver Bullet Band) How can I put all 3 in the same artist folder without changing artist name?

    Can you just create a new "Playlist", name it Bob Seger and drag what you want into the Playlist.
    File/New Playlist

Maybe you are looking for

  • What's wrong with my iPod Touch 4?

    Okay, so something's wrong with my iPod. I had other two issues, well, I still have, that led to this problem. My iPod wont turn sideways, even though the Portrait orientation isn't on, and an "Undo Typing" popup keeps appearing on my screen even tho

  • How do you keep the colors of an image true when you set it as a background?

    I have an image with lines in it and a black blackground. When I set it as a background : html {     background: url(../Images/backgroundimage.jpg);     background-repeat:auto;     background-position:center top; the black is a couple shades lighter

  • Pse 10 won't launch organizer unless i go thru premiere... also locks up during catalog back up

    tired of pse10 locking up and want to purchase 12... but when i try to backup my catalog, it locks up during "media size" at 32%... anyway to create a catalog back up?

  • Debtors Outstanding Balance

    Hi Experts, I need a report for Debtors Outstanding Balance(Unreconcilled Transactions)Bill Wise. It can be achieved by Business Partners>BP MasterData>AccountBalance -->Internal Reconcilliation. But everytime we have to go for each customer master d

  • Report Linking Error

    We encounter this problem when trying to hyperlink between reports: Error Msg: Report Linking Error. There was an error retrieving data from server. When linking to one report via another using hyperlinks of length greater than 1200 characters we rec