Help me in looping

I want to print
1
23
345
4567
but I stopped at
1
21
312
4123
coz i don't know how to ++ to the next line.
My code is
for ( a = 1; a <= height; a++)
    System.out.print(a);     
    for ( b =1; b <= a-1 ; b++)
       System.out.print(b);
       System.out.println();
}Anyone plz help me in telling me the logic ?thx

oic..thank you.
then how u do this
1
232
34543So, you don't understand your code, do you?
You can also make loops that decrements its index. That's basically what you need to add.for (int i = 1; i <= height; i++) {
    // This loops generate numbers from i to i+(i-1)
    for (int j = 0; j < i; j++) {
        System.out.print(i + j);
    // Here you need to print numbers in decreasing order
    // so find starting value, and stop condition
    System.out.println();
another problem is , how do u get 0 after 9 instead
of 10?
eg, 67890109876The modulo operator will make it (it divides one operand by another and returns the remainder as its result will make it.)

Similar Messages

  • Help with do loop

    do{     
    if((orderType != 'g') || (orderType != 'w')){     
    System.out.println("Please enter g or w only.");
    }while((orderType == 'g') || (orderType == 'w'));
    I need help with this loop... I have to make sure it will be able to pop the input back after the invalid input... i tried to fix it...wont stop and stay in same loop till it gets the valid before go to other loop... how? am i missing something?

    I know you've already been answered, but just a bit more...
    if((orderType != 'g') || (orderType != 'w'))That would always be true. All characters are either not equal to 'g' or not equal to 'w'.
    'x' : neither 'g' nor 'w'. Evaluates to true.
    'g' : not 'w', still evaluates to true.
    'w': not 'g', still evaluates to true.

  • HELP! FOR LOOP TO SCROLL THROUGH TABLE AND CREATE DATABASE LINK

    Hi,
    Here's the scenario, not much of a PL programmer, just basic SQL so really need some help people!
    I have 2 tables. 1 contains list of DB's and the other contains rules to follow.
    I need to create a loop that goes through the table containing the DB's and on each row a DB link is created (Only 1 link allowed!)
    Once created, the schema currently logged in with also has an account on the linked DB in order to run scripts- The scripts are stored centrally hence the requirement for the link to the target DB.
    There are numerous scripts that need to be executed and can all be called from 1 script, once executed the loop exists and the database link needs to be dropped.
    Once dropped, the first loop continues, creating a DB link for the next DB listed in the table (and all the scripts are fired again)
    This continues against all the DB's listed in the table.

    Hi BlueShadow,
    Thanks again for the response, you've hit the nail on the head. SQL scripts on a unix server, a loop goes through a table 1 at a time. Each row gets a link created and then all the scripts stored on the server are executed against the db linked to. So I'm assuming this is a loop within a loop.
    1 loop to go through the table to create the link and then another loop within once connected to execute all the scripts against the connected DB. Once the scripts are run, the loop exits and moves onto the next server and so on until all the servers have the scripts are run.
    It's PL/SQL scripts we're after and not shell scripts as this would free us from the OS constraints.
    We have to drop the links due to security. Any idea on o

  • Need help calling and looping custom classes

    Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
    L6:
    public class lab6
    public static void main(String[] args)
    Foreign camount = new Foreign();
    camount = new Foreign();
    camount.get();
    camount.print();
    camount.intake();
    camount.convert();
    camount.vertprint();
    System.out.println(camount);
    Foreign:
    import java.util.Scanner;
    public class Foreign
    private String country;
    private int choice;
    private float dollars;
    private float conversionValue;
    private float conversionAmount;
    public Foreign()
    country = "null";
    choice = 0;
    dollars = 0;
    conversionValue = 0;
    conversionAmount = 0;
    public void get()
         Scanner Keyboard = new Scanner(System.in);
              System.out.println("Foreign Exchange\n\n");
    System.out.println("1 = U.S. to Canada");
    System.out.println("2 = U.S. to Mexico");
    System.out.println("3 = U.S. to Japan");
    System.out.println("4 = U.S. to Euro");
    System.out.println("0 = Quit");
    System.out.print("\nEnter your choice: ");
    choice = Keyboard.nextInt();
    public void print()
    System.out.print("\nYou chose " + choice);
    public void intake()
         Scanner Keyboard = new Scanner(System.in);
              if (choice >= 1 && choice <= 4)
    switch (choice)
              case 1: System.out.println("\nU.S. to Canada");
                        conversionValue = 1.1225f;
                        country = ("Canadian Dollars");
                        break;
              case 2: System.out.println("\nU.S. to Mexico");
                        conversionValue = 10.9685f;
                        country = ("Mexican Pesos");
    break;
              case 3: System.out.println("\nU.S. to Japan");
                        conversionValue = 118.47f;
                        country = ("Japanese Yen");
    break;
              case 4: System.out.println("\nU.S. to Euro");
                        conversionValue = 0.736377f;
                        country = ("European Union Euros");
    break;
                   System.out.print("\nEnter U.S. dollar amount: ");
              dollars = Keyboard.nextFloat();
    public void convert()
    conversionAmount = conversionValue * dollars;
    public void vertprint()
    System.out.println("\nCountry = " + country);
    System.out.println("Rate = " + conversionValue);
    System.out.println("Dollars = " + dollars);
    System.out.println("Value = " + conversionAmount);
    public String toString()
    String line;
    line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
    return line;
    I appreciate any help anyone can give me. This is driving me crazy. Thanks.

    1. first you need to write method to get choice value from Foreign class.
    simply add this method.
       public class Foreign {
          // ... Add this
          public int getChoice() {
             return choice;
       }2. Then in your main, you can obtain with previos method.
    public static void main(String[] args) {
       Foreign camount = new Foreign();
       // remove this. you alredy create an instance in last statement.
       //camount = new Foreign();
       int choice = 0;
       do {
          camount.get();
          choice = camount.getChoice();
          // your process...
       } while (choice != 0);
    }

  • I need help organizing my Loop Library

    I've been researching this online but just cannot find the answer.
    I have GB11' (ver 6.0.4) operating on OS X Lion (ver 10.7.2).
    I've learned how to add custom loops by using drag-and-drop and Apple Loop Utility
    But I am still having troubles so I'd like to ask a few questions
    How do I add an entire folder of loops?
    I've tried drag-and-drop, GB seems to respond to it and would begin to load data, but I cannot seem to find it anywhere in the library.
    I could, however, add them individually and it works without a problem.
    I've tried Loop Utility too, but after saving the files it still would not appear in my GB library.
    (the files are in correct format .WAV and .AIFF)
    Where are the physical files of the custom loops located?
    So GB won't let me add an entire folder of loops, fine. I've managed to add a few individually, BUT! Where are the physical files?
    One discussion I found from here said that different versions of GB save the files in different locations.
    According to the article, I should be able to find them in /Library/Audio/Apple Loops/User Loops
    But on my Mac there is no "User Loops" folder. (They are not in "/Apple Loops for GB" either.)
    The bizzare thing is, these loops still work in GB!!!
    The reason I'm asking this is because I'd like to get rid of some undesired loops I added while testing.
    Also, I want to rename them so I can easily locate them.
    But this seem impossible because I cannot find the actual files..
    So the last question is
    How do I delete or rename the loops?
    If I can't rename it, at least let me delete it so I can reupload!!!
    The "Loop Index" does not contain any information about the loops I added either.
    Any help will be appreciated!!
    Thank you for your time!!

    allstreetball625 wrote: How do I add an entire folder of loops?
    I've tried drag-and-drop, GB seems to respond to it and would begin to load data, but I cannot seem to find it anywhere in the library.
    dropping the folder onto the browser pane _is_ indeed how you add loops. perhaps it's a setting in your project:
    http://www.bulletsandbones.com/GB/GBFAQ.html#missingloops
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    allstreetball625 wrote:
    (the files are in correct format .WAV and .AIFF)
    and they have been formatted as "Apple Loops"?
    allstreetball625 wrote:
    Where are the physical files of the custom loops located?
    http://www.bulletsandbones.com/GB/GBFAQ.html#myloopsstored
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    allstreetball625 wrote:
    How do I delete [...] the loops?
    see the end of the above FAQ entry
    allstreetball625 wrote:
    How do I [...] rename the loops?
    i don't believe you can from within GB, you'd have to drop the renamed file onto the loop browser to index it
    allstreetball625 wrote:
    The "Loop Index" does not contain any information about the loops I added either.
    there is usually more than 1 index file (not sll stored in the same place). see the reindexing entry for help in finding them:
    http://www.bulletsandbones.com/GB/GBFAQ.html#reindex
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • Help! apple loops missing

    Ok, I am a novice to Logic and I have a little issue.
    i am in the loop browser IN logic
    when i click all it says roughly 13,000
    here is the catch, i am trying to move all of my loops, voices, instruments, read/write over to my 7200rpm 1TB External
    when i go to library/audio/apple loops, only some are there but not all
    For example, when i am in a project and i search in the loop browser 808 (for a drum loop) it appears
    However, when i search 808 in my finder it finds nothing.
    Where is it?
    Also, is there a reason you cant edit/analyze roland loops in the mixer?
    or does this directly relate to the fact that i cannot find them in finder
    I stress that they are in my logic loop broser but not in the apple loops folder in my finder.

    Hi Huemanbing.F.O.I,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Logic Pro and Express: Rebuilding the Loop Index
    http://support.apple.com/kb/HT3443?viewlocale=en_US
    Cheers,
    - Judy

  • Help needed in loop in forms

    Hi all
    shayan here
    First of all sory for my last post in which i posted a lot of code...actuallly i want to describe my problem in details because it is really unknown to me......
    Now i will desdcrible it in simple.Hope fully all of you can understand and give me a idea to overcome this problem......
    My problem is that i had generated a record in tabluler form through Select statement......means i have made a coursor of select statement and via loop i added it to tabuler form element like this
    Registration Enrollment
    12321 312312
    231312 23123
    1232 123123
    Now i had added another display item in which ihave to calculate another thing like this
    Registration Enrollment CGPA
    12321 312312 2.14
    231312 23123 1.23
    1232 123123
    I have done it but problem is that it is showing the cgpa in front of only one item...
    not on all
    i dont know why??????
    also i want to insert this into another table like this....if this CGPA is final then insert it into final_CGPA table else it will update table with this CGPA.....
    I had written the Insert and update statement on when button pressed button but it is not updateing or inserting.....
    any help regarding this is highly appreciated
    Thanks in advance
    Shayan
    [email protected]

    Hello,
    Forms always creates the first record in each block, but if you want to add manually some more records, you have to use the Create_Record built-in for each new record you want to create in the block.
    Francois

  • Please Help With A Loop Using Vectors?

    I am developing a swing application and this loop has me completly stumped I have not worked with vectors alot, nut I have never seen this happen in a loop before:
    I am just going to post the loop because that is where this problem is happening.
    What I want to do is loop through CAT X amount of times and
    have an inner loop for SUBCAT X amount of times.
    fs is a formattedString class I have and eventually this text is appended to a JTextArea.
    Here is the Loop:
    Vector CAT = new Vector();
    Vector SUBCAT = new Vector();
    CAT = getCategories(Department);
    for (int i=0; i<CAT.size(); i++){
    String Category = CAT.elementAt(i).toString();
    fs.append("\nCategory: ",11);
    fs.append(Category,65);
    SUBCAT = getSubCategories(Category);
    }//End CATEGORY
    The part where I am completely stumped is, if I comment out the SUBCAT= part then the Text displays fine. If I dont it will just display the first string in the CAT Vector I have done a try and catch to see if there is an exception being thrown but there is none. The getSubCategories() method works fine b/c it is working at other parts of my program. (It Returns a Vector BTW). So commenting it out should really make no difference.
    Can anyone help me with this????
    Thanks in advance

    I will post what my output is in each scenario and maybe you can better understand what I am explaining:
    SCENARIO 1::::::::::::::::::::::::::::
    for (int i=0; i<CAT.size(); i++){
    fs.append("\nCategory: ",11);
    fs.append(CAT.elementAt(i).toString(),65);
    }//End CATEGORY
    Category: A Collars
    Category: Access Door
    Category: Aluminum
    Category: Anchors Drop In
    Category: Bits
    Category: Blades
    Category: Bolts, Nuts, Pins and Rivets
    Category: Bolts, Nuts, Pins, and Rivets
    Category: Canvas Connection
    Category: Caps
    Category: Caulking
    Category: Copper
    Category: Duct Mate
    Category: Ells
    Category: Flat Bar
    Category: Flex Duct
    Category: Galvanized
    Category: Grills
    Category: Insulation
    Category: Iron
    Category: Miscellaneous
    Category: Pipe
    Category: Reducers
    Category: Return Air Panels
    Category: Rings
    Category: Rod
    Category: Slide Gates
    Category: Spin Ins
    Category: Stainless Steel
    Category: Stick On With Damper
    Category: Tape
    Category: TDC
    Category: Tees
    Scenario 2:::::::::::::::::::::::::::::::::
    Category: A Collars
    for (int i=0; i<CAT.size(); i++){
    fs.append("\nCategory: ",11);
    fs.append(CAT.elementAt(i).toString(),65);
    SUBCAT = getSubCategories(CAT.elementAt(i).toString());
    }//End CATEGORY
    Now do you see:
    The SUBCAT = getSubCategories(CAT.elementAt(i).toString()); should not be affecting the loop. It should just be assigning a new Vector to SUBCAT. I know that it is missing the inner loop in this example, but this is how I found out the loops where not working right.

  • [HELP] Recovery Mode Loop - iPhone 5

    Dear all,
    Kindly help me. I'm trying to exit this ***ty Recovery Mode Loop. It is driving me crazy.
    Here is the story:
    Yesterday, I was updating my iDevices to the latest 6.1 iOS. When I tried to update my Mom's iPhone, suddenly, the iTunes sync logo appeard.
    I synced it with iTunes, and it gave me this message: "Your iphone is in Recovery Mode",
    I clicked "Restore iPhone"
    But after I had downloaded the latest update, the iPhone doesn't want to restore.
    I tried to Power it off, but it brings me back to the Recovery mode continuosly.
    It was never jailbroken (as there is no jailbreak for iPhone 5) + I have looked thru google but found nothing that helps!
    I tried (iREB and iRecovery and TinyUmbrella) all of them failed at putting the iPhone back to the normal state or to DFU mode.
    HELP!
    Thanks.

    Hi there nxtbardi,
    I would recommend taking a look at the troubleshooting steps found in the article below. If you used a computer to initiate the update, there is a possibility that the device created a backup before updating.
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    -Griff W.

  • Help with Video Loop

    Hi
    I've been at this for over 24 hours. I have a small video
    clip which is embedded in DW and uploaded...
    http://www.forpetsake.ca/about2.html
    Originally I purchased this ,mov from istockphoto.com and
    used QT pro to convert into a .flv. Once converted I brought it
    onto the Flash stage. In published settings I selected the 'loop'
    option and then exported out to a .swf. Once I embedded this .swf
    into my DW page, I uploaded all to my server including the .html
    created with the .swf, in fact I uploaded the .flv/.swf/.html into
    a seperate folder on my server.
    All I want to do is set this movie to loop, maybe pause for a
    couple seconds before each loop.
    I'm a simple person who only understands simple explanations.
    Can someone please walk me through the steps in Flash CS3 to
    get this short clip to loop.
    ps" The Property Panel selectors (loop-autoplay) make no
    changes whatsoever in DW CS3 with respect to this video.
    Thanks in advance for any help you can provide.

    If you're importing the FLV file into a SWF file (which is
    not recommended these days), then just add a gotoAndPlay(1) action
    to a keyframe you add at the very end of your Flash timeline.
    If, however, you use the FLVPlayback component, you can write
    ActionScript to listen for the "complete" event and tell the video
    to restart when that event is detected.
    Also, use SWFObject (
    http://blog.deconcept.com/swfobject)
    to embed a SWF into your HTML document. Dreamweaver and Flash's
    detection scripts aren't as good. (my two cents)
    HTH.

  • Weird Problem- Help With Logic Loops

    Hi all,
    I've been using Logic Express 8 for about 2 years and I've got a pretty good handle on things. However I keep having this small little problem and usually restarting the software fixes it, but not this time.
    My problem is this: I'm trying to make some beats using software instruments. So I click on "Drums and Percussion" then "Ultrabeat" then choose my drum kit. I start punching in my beats but Logic is playing some Apple Loop on top of it! Theres no notes on the track and yet it still plays this random beat! I can adjust the tempo and the beat adjusts to it.
    The problem is there is nothing there. Its a blank track, but this beat keeps playing.
    I used to just restart the program when it happened and it usually took care of it, however it won't fix it this time.
    I know it's probably some check box I don't have clicked or something but if someone could help me out, I'd be very appreciative.
    Thanks,
    Josh

    Ah yes!
    Thank you JG99!!!
    I forgot to go into the Ultrabeat menu, and turn off the "example beat" that they give you. I knew it was some checkbox that I didn't unclick or click.
    Thank you sir, you are a gentleman and a scholar.

  • SSIS Help For each Loop Container

    I need a little help with this process that I am developing. I am fairly new to SSIS so please bear with me. I have done research online so If I seem limited in my knowledge please apologize me.
    Requirement: I have a folder where we will have flat files monthly they could be one or more...
    each file will have the following name standard "123456.EEAKQ2.EASDREWA12A.BID".
    What I need to do is maintain a table which will have filename and date when it was added to the folder.
    I have created a package with the following components "For each loop" which grabs files from a source folder.
    This is where I am stuck. I need to grab the file name from the path and insert it into the table.
    Can someone help me with this?
    Thank you
    FM
    FM

    See similar requirement implemented here
    What you need is to declare and use a variable inside for each loop to get filename each time. Then you may use script task to check for pattern within the file for identifying correct files
    http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Help with Relay Loop

    In the attached picture inside the red circle is where I need help.  I'm trying to turn on 4 relays, it currently works but all the relays come on at the same time I need a 500ms pause between each relay and I can't seem to figure it out.  I would assume some kind of for loop would work I'm just not sure how to index the "Fan 1 switch", Fan 2 switch","Fan 3 switch", Fan 4 switch" into an array.
    Any help would be much appreciated
    Thanks,
    Attachments:
    help1.jpg ‏251 KB
    fanctrl_with_sound_detec1.vi ‏61 KB

    Here's one example, using just a numeric indicator as the state control. The State Machine is only slightly more involved.
    This example also shows one way to use an array to set your booleans to True/False.
    Good luck!
    Message Edited by LabViewGuruWannabe on 01-28-2008 12:36 PM
    Attachments:
    RelaysON-OFF.vi ‏47 KB
    RelaysON-OFF-BD.png ‏46 KB
    RelaysON-OFF-FP.png ‏32 KB

  • Need help with the loop

    I'm a beginner. I'm trying to get this output
    Initial number of stars:
    7
    Here's my program. What's wrong with it? Please help
    import java.io.*;
    class starWedge
    public static void main (String[] args ) throws IOException
    int numStars; // the number of stars
    int row ; // current row number
    int star; // the number of stars in this row so far
    BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
    String inputData;
    // collect input data from user
    System.out.println( "Initial number of stars:" );
    inputData = userin.readLine();
    numStars = Integer.parseInt( inputData );
    row = 1;
    while ( row <= numStars )
    star = 1;
    star = numStars - star;
    System.out.print("*");
    star = star + 1;
    System.out.println(); // end each line
    row = row + 1;

    Okay the one thing that I see immediately is that your while loop never actully exits. Not once. Why? Well simple your exit condition is the row <= numStars, yet nither numStars nor row actually change their values within the loop. In short row always equals 1 and thus never is equal to greater than numStars and the while loop does not terminate.
    Second thing is that your star drawing logic is not correct. Meaning you have not told to draw the specific number of stars in one given line. For starters the System.out.println() command should be in the loop not outside it. For your purposes a for-loop nested within a while-loop is much better.
    If you think you know what's wrong your program than read no further and go try it on your own. But if you still have no clue below is my modification of your code that actually produces the pattern you want, it might provide you with more hints.
    import java.io.*;
    class starWedge{
    public static void main (String[] args ) throws IOException{
         int numStars; // the number of stars
         int row ; // current row number
         int star; // the number of stars in this row so far
         BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
         String inputData;
         // collect input data from user
         System.out.println( "Initial number of stars:" );
         inputData = userin.readLine();
         numStars = Integer.parseInt( inputData );
         row = 1;
         while (numStars > 0){
         for(star = 1; star<=numStars; star++){
              System.out.print("*");
         numStars = numStars - 1;
         System.out.println(); // end each line
    }

  • Need help w/ for loop, a do loop, and a do-while loop.

    Hello I have been trying to write a program that uses a for, do, and a do-while loop, but I am having trouble. I need the program that will prompt the user to enter two numbers. The first number must be less than the second number. I need to use a "for loop", a "do loop", and a "do-while loop" to display the odd numbers between the first number and the second number. For example, if the user entered 1 and 8, the program would display 3,5,7 three different times (one for each of the loops). Please help if you can. Thanks.

    boolean2009 wrote:
    Thank all of you all for responding.Youre welcome.
    Yes this is my homework, but my major does not even involve java i just have to take the class.Not our problem.
    And yes we are suppose to have all three in one program I do not know why,So you can learn all three types of loops (there is also an enhanced for loop to learn later on).
    but I just do not understand programming nor do i really want to.Once again not our problem.
    If anybody could help it would be much appreciated. thanks.Yes, a lot of people are willing to help you. No, none of them will do it for you. What you need to do is attempt the code and when you get stuck, post your code using the code button, include error messages, indicate which lines in your code genereate those error messages and ask specific questions.

Maybe you are looking for