How to make this never ending loop stop!

Somewhere in this code where im printing stars, i have a loop that i cant stop from continuing. The instrucitons say set the line<=30 and that i set line = 5 in the for loop. Im supposed to get a pyramid shape of stars made with 5 lines. IT should be adding by 2's at it goes down, such as 1,3,5,etc... Here is a picture of it.
import chn.util.*;
public class Pictures
  void printTable(int rows,int columns)
  {   for (int row = 1; row <= rows; row++)
   for (int col = 5; col <= columns; col++)
   System.out.println ( );
void pyramid (int n)
   int line, spaces, stars, loop;
   for (line = 5; line <=30; line--)
      spaces = line - 1;
      for (loop = 1; loop <= spaces; loop++)
         System.out.print (" "); // print a blank space
      stars = n- line + 2;
      for (loop = 1; loop <= stars; loop++)
         System.out.print ("*");
   System.out.println();
   public static void main (String[ ] args)
      Pictures pic = new Pictures ( );
      ConsoleIO keyboard = new ConsoleIO ( );
      String get;
      pic.printTable (4, 6);
      get = keyboard.readLine ( ); // freezes the output screen to see the picture
      pic.printTable (11,12);
      get = keyboard.readLine ( );
      pic.pyramid (10);
      get = keyboard.readLine ( );
      pic.pyramid(25);
      get = keyboard.readLine ( );
}

for (line = 5; line <=30; line--)line will be 5, then 4, then 3, 2, 1, 0, -1, -2, ...
And you'll keep going as long as it's <= 30. That is, it will stop when line > 30.
How will line ever be > 30 following that pattern? (Well, it will, when it wraps from Integer.MIN_VALUE to Integer.MAX_VALUE.)
You need to change your initial value or your terminating condition or your increment step. Up to you to figure out what's appropriate for what you're trying to do.

Similar Messages

  • How to make a never-ending(looping) page in DW?

    I want to make a page which repeats itself on the ipad when you scroll in any direction. In essense a never ending page.
    Jus began using HTML5 for our app.

    Hi
    You can do this just by repeating the code, but this is a sure way to stop anyone visiting your site -
    The 'new' page is downloaded every time, (complete waste of bandwidth).
    Your user will think that there is something wrong, so will go somewhere else.
    On mobile devices bandwidth is now often limited and/or paid for.
    A site that just repeats itself will on devices that can display the entire page download all the pages, ad infinitum.
    PZ

  • AdamSync from AD to LDS goes into a continuous never ending loop... can't figure this out.

    I THINK I've got this thing configured up to the point where it should be able to sync.  The XML config is set to just grab a single OU with roughly 12 accounts in it.
    Everything seems to connect OK, then it does a ton of "Processing Entry", even though there are only a few accounts in this OU.
    Then it begins to do "Adding target object..." and gets stuck in a never ending loop.
    Can someone point me in the right direction on how to troubleshoot this?
    This is what the log looks like:
    ==========================
    Adamsync.exe v1.0 (6)
    Establishing connection to target server localhost:6389.
    There is already an active sync session in progress. 
    Please allow the session to complete, or use -mai to seize the role.
    Saving Configuration File on CN=Test,DC=domain,DC=org
    Saved configuration file.
    ADAMSync is querying for a writeable replica of 10.10.10.10.
    Error: DCLocator call failed with error 1355. Attempting to bind directly to string.
    Establishing connection to source server 10.10.10.10:389.
    Using file .\dam9280.tmp as a store for deferred dn-references.
    Populating the schema cache
    Populating the well known objects cache
    Starting synchronization run from dc=domain,dc=org.
    Starting DirSync Search with object mode security.
    Processing Entry: Page 1, Frame 1, Entry 0, Count 0, USN 0
    Processing source entry <guid=94f6d930da2339439df75278a02accae>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 1, Frame 1, Entry 1, Count 1, USN 0
    Processing source entry <guid=bf15bc4b684ece4f99010548e79decb0>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 1, Frame 1, Entry 2, Count 1, USN 0
    Processing source entry <guid=fcea01637658134eab7ec74fe022d4fe>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 1, Entry 35, Count 1, USN 0
    Processing source entry <guid=5e768f4392863b4d86935e6bf01acc25>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 1, Entry 36, Count 1, USN 0
    Processing source entry <guid=b5d263a264aad045b8f42f19b49dd844>
    Previous entry took 0 seconds (16, 0) to process
    Processing Entry: Page 3, Frame 1, Entry 37, Count 1, USN 0
    Processing source entry <guid=f19994051c804846b7bcbd066d9e9d40>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 1, Entry 38, Count 1, USN 0
    Processing source entry <guid=b16cd765bafa4f4d8649d91f0f055e5f>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 1, Entry 39, Count 1, USN 0
    Processing source entry <guid=6be6a7d551978445aafd3803e60dc560>
    Processing in-scope entry 6be6a7d551978445aafd3803e60dc560.
    Adding target object CN=User Name,OU=Staff Accounts,OU=Users,OU=ITS,CN=Test,dc=domain,dc=org.
    Adding attributes: sourceobjectguid, instanceType, objectSid, sAMAccountName, lastagedchange, objectclass, 
    Adding target object CN=User Name,OU=Staff Accounts,OU=Users,OU=ITS,CN=Test,dc=domain,dc=org. Requesting replication of parent.
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 2, Entry 0, Count 0, USN 53438354
    Processing source entry <guid=bbb4a760a8281741a11d9331efaa3d7a>
    Processing in-scope entry bbb4a760a8281741a11d9331efaa3d7a.
    Adding target object OU=Staff Accounts,OU=Users,OU=ITS,CN=Test,dc=domain,dc=org.
    Adding attributes: objectClass, instanceType, sourceobjectguid, lastagedchange, 
    Adding target object OU=Staff Accounts,OU=Users,OU=ITS,CN=Test,dc=domain,dc=org. Requesting replication of parent.
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 3, Entry 0, Count 0, USN 52660067
    Processing source entry <guid=8d3ef319dff31f47819632af2da5df2c>
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 2, Entry 0, Count 0, USN 53438354
    Processing source entry <guid=bbb4a760a8281741a11d9331efaa3d7a>
    Processing in-scope entry bbb4a760a8281741a11d9331efaa3d7a.
    Adding target object OU=Staff Accounts,OU=Users,OU=ITS,CN=Test,dc=domain,dc=org.
    Adding attributes: objectClass, instanceType, sourceobjectguid, lastagedchange, 
    Adding target object OU=Staff Accounts,OU=Users,OU=ITS,CN=Test,dc=domain,dc=org. Requesting replication of parent.
    Previous entry took 0 seconds (0, 0) to process
    Processing Entry: Page 3, Frame 3, Entry 0, Count 0, USN 52660067
    Processing source entry <guid=8d3ef319dff31f47819632af2da5df2c>
    Previous entry took 0 seconds (0, 0) to process
    ===================================================

    Hi,
    Are there any error messages from the event log?
    Here is a KB article which describes a similar issue below I suggest you refer to:
    Error message when you use the Adamsync tool in Windows Server 2003: "Error: We seem to be in an infinite recursive loop"
    http://support2.microsoft.com/kb/926933
    Best Regards,
    Amy

  • Something keeps trying to download on my mac and I don't know what it is. It is not in the apple store and just comes out nowhere and request for my password to download something and I don't know what it is. How to make this stop?

    Something keeps trying to download on my mac and I don't know what it is. It is not in the apple store and just comes out nowhere and request for my password to download something and I don't know what it is. How to make this stop? It pops up every single day.

    Erica,
         I can, with 99.99% certainty, tell you that you are absolutely right in not wanting to download or install this "Helper," whatever it is (but we can be equally certain it would not "help" anything).
         I cannot comment as to Oglethorpe's recommendation of 'adwaremedic'; I am unfamiliar with it.  His links to the Apple discussion and support pages warrant your time and attention.
         It might be really simple -- Trying looking in your Downloads folder, trash anything that you don't know with certainty is something you want to keep, and then Secure Empty your Trash. Then remove the AdBlock extension, LastPass, and Web of Trust extensions to Safari and re-boot. If the issue goes away, still be extraordinarily careful in the future.
         Unfortunately, it's probably not going to be that simple to get rid of, in which case I'd then try the line by line editing in HT203987. 
         I have no further suggestions (other than a complete wipe and re-install...but that's a pain because trying to restore from Time Machine would simply ... restore the Mal).
       For the rest of us, please post when you find a solution.
         Best.
         BPW
      (Also, try to edit your second post -- black out your last name on the screenshot and re-post it for others)

  • Problem on I-TUNES,,,says my computer is not authorized to listen to a song I purchased....when I go to STORE/AUTHORIZE..it says my computer is already authorized....never-ending loop...won't play on IPOD either,,,HELP !

    Purchased a song on I-tunes....won't let me listen to it...says my computer is not authorized...first time in 3 years that this problem occured ...I went to STORE/AUTHORIZE ,,,and it says my computer is already authorized....never-ending loop ...HELP ! Won't play on Ipod either

    Delete and redownload it if doing so is free in your country.
    (88542)

  • Wireless printer is setup, but the HP Installer Setup program is in a never-ending loop

    Wireless printer is setup (HP Officejet 4500), but the HP Installer Setup program is in a never-ending loop.  It says "Fatal error during installation." and keeps trying to uninstall/reinstall/ etc etc etc.  Printer is setup and runs fine, just need to get rid of this crazy loop - any guidance?
    Dee
    This question was solved.
    View Solution.

    Which OS is installed?
    I recommend that you uninstall the printer software from the HP folder in start-->All Programs -->HP --> uninstall software
    After the uninstall is completed and your system restarted install and configure the printer again.
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • How to make this pattern?

    Hello guys Please I am looking for advice how to make this kind of pattenr in pohtoshop- you can see it on background- the rounded one- en the end whole piece makes nice surface.
    http://vladstudio.deviantart.com/art/Typographic-World-Map-106395788
    thank a lot

    Sometimes a patten is defined for some pixel size and may even need to have the document rotated to have the proper orientation for the pattern. For example a frame pattern for a one inch wide strip.  An Action can be created to add the pattern to a mitered 1" wide strip at 300 dpi  on the left side then rotate the document for the other side rotate back and dupe and flip the frame side added.
    If you search the web there are a countless number of patterns that can be downloaded for free textures like woods ,paper, textiles etc.

  • TS2634 I bought a composite AV cable with 30 pin connector at a proper apple store for my ipad 2 which no longer works now i have updated to ios7 - please advise how to make this work ?

    I bought a composite AV cable with 30 pin connector at a proper apple store for my ipad 2 which no longer works now i have updated to ios7 - please advise how to make this work ?

    I have the same problem.
    Two similar discussions:
    https://discussions.apple.com/message/23081658#23081658
    https://discussions.apple.com/message/23281391#23281391
    I have not yet seen any official response to the question: "Is the Apple AV Composite cable fully supported with 30pin connector devices upgraded with iOS7 - specifically ? - eg. iPad 2, iPhone 4, iPhone 4s"
    If it is not currently supported is that then due to a bug / oversight and in that case is it something that will be fixed in the near future?
    Please let us know what feedback you got from asking Apple support.

  • How to make this in Adobe Photoshop CS5? PLEASE Help!

    Hey guys, i reallllllllly  want to know how to make this image in adobe photoshop.... the cone around the forecast track. Can you guys please show me how to do this? Id greatly appreciate it!

    There's a lot implied here, but you're not going to get around having to do the following in general:
    Use an unmarked map as a background.
    Draw shapes on layer(s) above the background and make them partially transparent.
    Obviously the key is to draw shapes that express the "cone of uncertainty" exactly as you want it to look, and with a minimum of fuss.
    I'd suggest drawing shapes with Path tools, then filling the shapes, applying a stroke (for the edge border), and using masking to hide parts you don't want to show (or which overlap with the other parts you're drawing).
    Are you needing to do this over and over or just once?
    -Noel

  • How to make this effect in Keylight?

    Hi, I have question, how to make this effect in Keylight?
    I know that this overlay is added here:
    http://oi57.tinypic.com/1174fup.jpg
    Photos:
    http://iv.pl/images/18475588964010299091.jpg

    Keylight what? All I see is some effect similar to Leave Color, a.k.a the Pleasantville effect that made the rounds 10 years ago. It may require additional masking and otehr effects, but definitely not something that is specifically related to Keylight...
    Mylenium

  • How to make this work flow?

    Hi,
    In a target database such like MySQl, I define a colum role to store the roels in SIM. Then, I want to make a post-workflow that set the account with related role which is defined in the DB after reconciliation and move those accounts from this DB to a specified organzation.
    How to make this workflow?
    If anyone know about this, kindly help me...
    thanks..

    Just a thought... Are you able to run this as activesync? If you use activesync you could just use a form or metaview to merge (or replace) your role value with waveset.roles and set the org for accounts that correlate.
    -Rob

  • How to make this work with Firefox, HELP!

    Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • How to make this animation in TwitchPlugin?

    Hi, I have question, how to make this effect and animation in twitch.
    Effect:
    Animation:
    http://youtu.be/UIrSSYjW5-A?t=15s

    If you bought the plug-in you have a bunch of tutorials.
    If you are thinking about buying the plug-in take a look at the tutorials provided by Video CoPilot
    https://www.videocopilot.net/products/twitch/
    If you are still lost AE Basics

  • Anyone knows how to make this code to netbeans??

    anyone knows how to make this code to netbeans?? i just want to convert it into netbeans... im not really advance with this software... anyway..just reply if you have any idea...or steps how to build it... etc.... thanks guys...
       import javax.swing.*;
       import javax.swing.table.*;
       import java.awt.*;
       import java.awt.event.*;
       import java.util.regex.*;
       public class FilterTable {
         public static void main(String args[]) {
           Runnable runner = new Runnable() {
             public void run() {
               JFrame frame = new JFrame("Sorting JTable");
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               Object rows[][] = {
                 {"AMZN", "Amazon", 41.28},
                 {"EBAY", "eBay", 41.57},
                 {"GOOG", "Google", 388.33},
                 {"MSFT", "Microsoft", 26.56},
                 {"NOK", "Nokia Corp", 17.13},
                 {"ORCL", "Oracle Corp.", 12.52},
                 {"SUNW", "Sun Microsystems", 3.86},
                 {"TWX",  "Time Warner", 17.66},
                 {"VOD",  "Vodafone Group", 26.02},
                 {"YHOO", "Yahoo!", 37.69}
               Object columns[] = {"Symbol", "Name", "Price"};
               TableModel model =
                  new DefaultTableModel(rows, columns) {
                 public Class getColumnClass(int column) {
                   Class returnValue;
                   if ((column >= 0) && (column < getColumnCount())) {
                     returnValue = getValueAt(0, column).getClass();
                   } else {
                     returnValue = Object.class;
                   return returnValue;
               JTable table = new JTable(model);
               final TableRowSorter<TableModel> sorter =
                       new TableRowSorter<TableModel>(model);
               table.setRowSorter(sorter);
               JScrollPane pane = new JScrollPane(table);
               frame.add(pane, BorderLayout.CENTER);
               JPanel panel = new JPanel(new BorderLayout());
               JLabel label = new JLabel("Filter");
               panel.add(label, BorderLayout.WEST);
               final JTextField filterText =
                   new JTextField("SUN");
               panel.add(filterText, BorderLayout.CENTER);
               frame.add(panel, BorderLayout.NORTH);
               JButton button = new JButton("Filter");
               button.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                   String text = filterText.getText();
                   if (text.length() == 0) {
                     sorter.setRowFilter(null);
                   } else {
                     try {
                       sorter.setRowFilter(
                           RowFilter.regexFilter(text));
                     } catch (PatternSyntaxException pse) {
                       System.err.println("Bad regex pattern");
               frame.add(button, BorderLayout.SOUTH);
               frame.setSize(300, 250);
               frame.setVisible(true);
           EventQueue.invokeLater(runner);
       }

    its okay onmosh.....what we need to
    this...forum....is to have a good......relationship
    of programmers......and to start with .....we need to
    have a good attitude........right.....???.....no
    matter how good you are in programming but if you did
    not posses the right kind of attitude....everything
    is useless.....in the first place....all we
    want....is just to ask...some....help....but
    conflicts......but unluckily......we did not expect
    that there are members in here which......not
    good...to follow.....just as suggestion for those
    people not having the right kind of attidude...why
    can't you do in a very nice message sharing in a very
    nice....way....why we need to put some
    stupid....stuff...words.....can't you live with out
    ******* ****....its not.....lastly especially you
    have your children right now and people around...that
    somehow......idiolize...you even me....is one of
    them......but showing but attitude....is not
    good......tnx....hope you'll take it this....in the
    positive side.....be optimistic...guys....the
    world..is not yours....all of us will just past
    away....always..remember that one.....treasure..our
    stay in this....temporary home.....which...is
    world....Whoa. That post seems to be killing my brain.
    URK
    Join........us..........do not be..........afraid.......

  • A never ending loop...not sure why?

    When I run my current procedure, it seems to be getting caught in a never ending loop, not entirley sure what the problem is...? I'm not quite the expert so if possible, the more detail in the explaniation the better...thanks!!
    --The cursors
    cursor konami_mlb_pitchers_crsr is
       select player_id_1032
       from customer_data.cd_baseball_pit_ytd_stats
       where split_number = -3
         and game_type_id = 1
         and sequence = 0
         and season_id = iSeasonID
       order by player_id_1032;
    cursor konami_mlb_career_pit_crsr is
       select ytd.player_id_1032,
          ytd.player_id,
          ytd.moniker,
          ytd.last_name,
          sum(ytd.games_played),
          trunc(sum(ytd.outs_pitched) / 3) || '.' || mod(sum(ytd.outs_pitched), 3) as innings_pitched,
          sum(ytd.complete_games),
          sum(ytd.shut_outs),
          sum(ytd.wins),
          sum(ytd.losses),
          to_char((sum(ytd.wins)) / decode(sum(ytd.wins) + sum(ytd.losses), 0, 1, null, 1, sum(ytd.wins) + sum(ytd.losses)), '0d000') as winning_pct,
          trim(to_char( (9 * sum(ytd.earned_runs)) / (sum(ytd.outs_pitched) / 3) , '990d00')) as era,
          sum(ytd.strikeouts),
          sum(ytd.saves),
          sum(ytd.hits),
          sum(ytd.home_runs),
          sum(ytd.walks),
          sum(ytd.hit_batters),
          sum(ytd.earned_runs),
          sum(ytd.runs)
       from customer_data.cd_baseball_pit_ytd_stats ytd,  customer_data.cd_baseball_roster rost
       where ytd.split_number = -3
         and ytd.game_type_id = 1
         and ytd.sequence = 0
         and rost.player_id = ytd.player_id
         and rost.league_id = iLeagueID
         and ytd.season_id <= iSeasonId   
         and ytd.active_record != 'R'
         and ytd.player_id_1032 in
        --Includes Players that were on the DL for the entire season                                          
          select player_id_1032
         from customer_data.cd_baseball_roster r
         where r.year_last = 2008
         and r.league_id = iLeagueID
         and r.player_id_1032 is not NULL
         group by ytd.player_id_1032,ytd.player_id, ytd.moniker,  ytd.last_name;   --Where the cursor gets opened
    open konami_mlb_pitchers_crsr;
       loop
          fetch konami_mlb_pitchers_crsr into pitcher;
          exit when konami_mlb_pitchers_crsr%notfound;
          open konami_mlb_career_pit_crsr;
          loop
             fetch konami_mlb_career_pit_crsr into pitcher_record;
             exit when konami_mlb_career_pit_crsr%notfound;
             utl_file.put_line(file_handle, pitcher_record.first_name || ',' ||
                                            pitcher_record.last_name || ',' ||
                                            pitcher_record.id || ',' ||
                                            pitcher_record.games_played || ',' ||
                                            pitcher_record.innings_pitched || ',' ||
                                            pitcher_record.complete_games || ',' ||
                                            pitcher_record.shutouts || ',' ||
                                            pitcher_record.wins || ',' ||
                                            pitcher_record.losses || ',' ||
                                            pitcher_record.winning_pct || ',' ||
                                            pitcher_record.era || ',' ||
                                            pitcher_record.strikeouts || ',' ||
                                            pitcher_record.saves || ',' ||
                                            pitcher_record.hits || ',' ||
                                            pitcher_record.homeruns || ',' ||
                                            pitcher_record.walks || ',' ||
                                            pitcher_record.hit_batters || ',' ||
                                            pitcher_record.earned_runs || ',' ||
                                            pitcher_record.runs);
          end loop; -- end loop through the stats for each pitcher
          close konami_mlb_career_pit_crsr;
       end loop; -- end loop through all the pitchers
       close konami_mlb_pitchers_crsr;

    You don't seem to be using the cursor iterator variable "pitcher" when you print the data to the file. You are not even passing any parameter to the "konami_mlb_career_pit_crsr" cursor. As such the first cursor "konami_mlb_pitchers_crsr" appears to be redundant.
    Maybe the loop is time-consuming (instead of "never-ending"), and if you wait long enough, it will end. In the meantime, you may want to tune your logic.
    isotope

Maybe you are looking for

  • Imac came with moutain lion can i transfer this onto my macbook

    hi i bought imac this year with moutain lion on the system, i also have a macbook pro with snow leopard and would like to put mountain lion on this also, now can i somehow get it from computer to macbook or do i have to download it in app store? ther

  • WBS system status

    Dear Experts, We cannot perform settlement due to "Asset 2000 5010000125-0 is incomplete, check the asset". What must we do so that we can proceed with the settlement? Helpful answer will be rewarded. Thanks in advance.

  • LDB PNP authorization check authorization object

    Hi, I have used LDB PNP for HR reports. We are using the authority check also, but the problem is all the records/data for all the people is being read by the report where some of the people data should not have been read as they belong to some other

  • Indesign 3.0 can't print to adobepdf

    I am having an issue where I can't print ANYTHING in InDesign 3.0 to a PDF file. Not sure what is wrong but it will not work, period. Any advice?  Thanks.

  • Can Adobe Air 3.1 be deployed via Group Policy?

    I am looking for a definitive answer as to whether or not Adobe Air 3.1 can be deployed via Group Policy?  I've found material on the web that is very contradictory.  Can it be done and if so how?  I can't find any solid instructions on how to deploy