Navigating the array on menu

import java.util.*;
public class Main {
     * @param args the command line arguments
    private static void bubbleSort(int[] x) {
    int n = x.length;
    boolean doMore = true;
    while (doMore) {
        n--;
        doMore = false;
        for (int i=0; i<n; i++) {
            if (x[i] > x[i+1]) {
                int temp = x; x[i] = x[i+1]; x[i+1] = temp;
doMore = true;
public static void main(String[] args) {
while(true){
System.out.println("What do you want to perform choose :\n 1. Searching\n 2. Sorting\n 3. Exit\n ");
Scanner input = new Scanner(System.in);
switch(input.nextInt()){
case 1 : System.out.println("1. Linear Searching\n2. Binary Searching\n");
switch(input.nextInt()){
case 1 :System.out.println("Linear Search: ");
continue;
case 2 :System.out.println("Binary Search: ");
break;
continue;
case 2 : System.out.println("Please provide the size of the array between 5 to 30; ");
int arrays = input.nextInt();
System.out.println("If you want to supply the number between 1 to 100 press 1,or\n2 to generate it ramdomly: ");
switch (input.nextInt()){
case 1: int num = 0;
int[] arrSize = new int[30];
for(int i = 0; i <=arrSize.length; i++){
arrSize[i] = num;
System.out.println("Please enter number on index"+i+":");
num=input.nextInt();
break;
case 2: int[] arr = new int[30];
Random random = new Random();
for (int idx = 1; idx <= 30; ++idx){
int randomInt = random.nextInt(100);
arr[idx - 1] = randomInt;
System.out.println(Arrays.toString(arr));
System.out.println("\n");
System.out.println("What Sorting algorithm you want to ferform?\n1. Bubble Sorting \n2. Selection Sorting\n3. Insertion\n");
switch (input.nextInt()){                                              
case 1 ://code to call bubble sort method
break;
continue;
//continue; //starts the loop again
case 3 : System.exit(0);
break; //exists the loop
default: System.out.println(input.nextInt()+ " is not a valid charachter , please try again");
}//end of while loop
}Sorry im new to this,i have a code there im now developing sorting algo. in my code the user provide a size of the array between 5 to 30 then the user will choose if he/she wants to supply the numbers between 1to100 or these are generated randomly. My problem is that if the user difine the array size, then after the array size given it will ends the loop up to 30. all i want is if the user difine array size 5 only 5 index will prompt. please help im also trying here any advise?
Edited by: limuh on Aug 25, 2008 4:20 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

thanks for the reply. my code now works on the problem:) but the bubblesort method not performing its task. how can i call the bublesort method to sort my values in the array?
case 2 : System.out.println("Please provide the size of the array between 5 to 30; ");
                                        int num = 0;
                                        int arrays = input.nextInt();
                                        for(int i = 0; i <=arrays; i++){
                                 System.out.println("If you want to supply the number between 1 to 100 press 1,or\n2 to generate it ramdomly: ");
                                    switch (input.nextInt()){
                                        case 1: int[] arrSize = new int[arrays];
                                                for(int i = 0; i <=arrSize.length; i++){
                                                    arrSize[i] = num;
                                                    System.out.println("Please enter number on index"+i+":");
                                                    num=input.nextInt();
                                        break;
                                        case 2: int[] arr = new int[arrays];
                                                Random random = new Random();
                                                for (int idx = 1; idx <= arr.length; ++idx){
                                                int randomInt = random.nextInt(100);
                                                arr[idx - 1] = randomInt;
                                                System.out.println(Arrays.toString(arr));
                                                System.out.println("\n");
                                        System.out.println("What Sorting algorithm you want to ferform?\n1. Bubble Sorting \n2. Selection Sorting\n3. Insertion\n");
                                            switch (input.nextInt()){
                                                case 1 : new Main().bubbleSort(x);     
                                                break;
                                        }

Similar Messages

  • While navigating the pages in Menu Not showing correct jspx

    Hi ,
    We develop 10 ADF Pages and attached those pages to Menu . Now while going to page A its not showing pagA.jspx in address Bar ( though its showing correct Page ) But when navigating to PageB
    its showing PAgeA.jspx in ( Address Bar ) but its showing correct pageB content . Why this behave like this ...??
    Edited by: [email protected] on Jul 22, 2009 9:15 AM

    This is not an ADF issue - this is a core JSF way of working.
    Why would your end user care about the address anyway?
    You can set your navigation case to be redirect to get around this.

  • When using the right mouse button in Yahoo mail inbox (Firefox 8.0.1, Win 7, Yahoo Mail Plus) the Firefox navigation window (Back, Forward etc...) is on top of the Yahoo email menu (Open, Print, Reply etc...). This happens in Firefox safe mode as well.

    This also happened in Windows XP which I was using until recently.
    The Yahoo mail menu is there but the Firefox menu is on top of it. I tried Firefox safe mode with everything disabled and the problem still happened. I tried Yahoo mail in IE 9 and the right mouse button works correctly.

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    Use a compressed image type like PNG or JPG to save the screenshot and make sure that you do not exceed the maximum file size (1 MB).
    Make sure that you do not run Firefox in full screen mode (press F11 or Fn + F11 to toggle; Mac: command+Shift+F).<br />
    If you are in full screen mode then hover the mouse to the top to make the Navigation Toolbar and Tab bar appear.<br />
    You can click the Maximize button at the top right to leave full screen mode or right click empty space on a toolbar and use "Exit Full Screen Mode" or press F11.<br />

  • In SharePoint 2013 navigation, is it possible to add a custom link only to the left-hand menu without getting it in to the top menu dropdown?

    If I want to add a custom link to the left-hand navigation menu In a SharePoint 2013 sub-site, it can be done by visiting
    Site Settings à Navigation section and adding the link under
    Structural Navigation: Editing and Sorting section. However, this will automatically add a matching link to the top menu as a dropdown.
    (Note that Global Navigation is set to “Display the same navigation items as the parent site” where “Parent is using Structural Navigation.” and Current Navigation is set to “Structural Navigation:
    Display only the navigation items below the current site”)
    Is there a way to just add a custom link only to the left-hand menu without getting it in to the top menu dropdown?

    Hi Asanka,
     Please refer the below link which may help you to resolve your problem.
    http://blog.navantis.com/configuring-sharepoint-2013-navigation-to-span-site-collections/
    If its not helping you please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • What happens to the array built inside a subvi

    Hi
    My operation inside a subvi goes like this, i acquire data from a source continuously in a loop, build it in the loop and pass it out of the loop. I complete the processing of the built array in the same subvi and come out of it.
    I have the following doubts ;
    1. Does the memory allocated for building the array gets cleared when i come out of the sub vi.

    The answer is no, the memory allocated by the sub-VI will not be released, it will remain in use until the next time the sub-VI is called...then it might reduce or increase it's size depending on how it works. You can improve the performance by ensuring that the VI always works on the same memory (do not build arrays but initialize a shift register only at the first run and then use the replace array elements function instead e.g.). Building arrays in a loop is a no no.
    If the VI is only to run now and then you can force the memory to be released either by loading the VI dynamically and then closing all references to it when you are finished with it for that run...or you can use the Request Deallocation function that you can find on the advanced -> data manipulati
    on menu in LV7. If the VI runs all the time your better off leaving it in memory.
    MTO

  • How to get The Collabration Admin Menu

    Hi All,
    Please Any one can tell me how to get  Collabration Admin menu in Netweaver like How we get System Administration , Content Administration and User Administration
    I want to create E-Mail Transport in the Groupware Admin Document they have given that i have to go through the following link
    To configure an e-mail transport, choose Collaboration Administration ¨ Collaboration
    Content ¨ Configure Groupware Transport ¨ Mail Transport from the top-level navigation
    bar.
    But I am not able to find the Collabaration Admin Menu when i looged in with my user id whcich is assigned with superadmin role.
    Can any one help me out
    Thanks and Regards
    Prasad.Y

    Hi Prasad,
    To get all these admin. iViews u should have assigned the "Administrator" role(superadmin role is different) to ur userid and that can be assigned by only Administrator.
    After gaining the access u have to create System for mail server.
    Then navigate to
    System Admin.->System Configuration->Knowledge Management->Collaboration->Groupware Transports ->Mail Transport.
    Fill in the parameters i.e. the ip of the mail server and the name of the folder where you want the sent messages to be stored and the name of the system created in step 1 in the system alias field.
    Restart the J2ee engine for the changes to take effect.
    With best regards,
    Amol.

  • How to get The Collbration Admin menu in EP of  Netweaver

    Hi All,
    Please Any one can tell me how to get  Collabration Admin menu in Netweaver like How we get System Administration , Content Administration and User Administration
    I want to create E-Mail Transport in the Groupware Admin Document they have given that i have to go through the following link
    To configure an e-mail transport, choose Collaboration Administration ¨ Collaboration
    Content ¨ Configure Groupware Transport ¨ Mail Transport from the top-level navigation
    bar.
    But I am not able to find the Collabaration Admin Menu when i looged in with my user id whcich is assigned with superadmin role.
    Can any one help me out
    Thanks and Regards
    Prasad.Y

    Hi Prasad, i have a user that have the followin roles:
    -content_admin_role
    -super_admin_role
    And that user have the 'System Administration' tab in the top level navigation.
    try with these roles to access:
    System Administration > System Configuration > Collaboration > Groupware Transports > Mail Transport
    I hope it helps u.
    regards
    Gregory.

  • How to create a button with the drop-down menu?

    I want to create a button with the drop-down menu, which is like the 'back' on the tollbar in IE. I heard JPopupMenu can reach the certain result, but the button hadn't a down arrow. Who can help me?

    i have made something like this :
    //======================================================================
    package com.ju.guiutils
    import java.awt.*;
    import java.awt.event.*;
    import java.net.URL;
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import javax.swing.plaf.basic.BasicComboBoxUI;
    * @version 1.0 14/04/02
    * @author Syed Arshad Ali <br> [email protected]<br>
    * <B>Usage : </B> ButtonsCombo basically performs function button + JComboBox, if we have different options for
    * <BR>same button then we can use this ButtonsCombo.
    *<BR> By the way there is no button at all in <I>ButtonsCombo</I>
    public class ButtonsCombo extends JComboBox {
    //===================================================================================
    * Create ButtonsCombo with default combobox model
    public ButtonsCombo () {
    super ();
    init ();
    //===================================================================================
    * Creates a ButtonsCombo that takes it's items from an existing ComboBoxModel.
    public ButtonsCombo ( ComboBoxModel model ) {
    super ( model );
    init ();
    //===================================================================================
    * Creates a ButtonsCombo that contains the elements in the specified array.
    public ButtonsCombo ( Object [] items ) {
    super ( items );
    init ();
    //===================================================================================
    * Creates a ButtonsCombo that contains the elements in the specified Vector.
    public ButtonsCombo ( Vector items ) {
    super ( items );
    init ();
    //===================================================================================
    private void init () {
    setBorder ( BorderFactory.createBevelBorder ( BevelBorder.RAISED ) );
    setRenderer ( new ComboRenderer() );
    setUI ( new ComboUI() );
    addMouseListener ( new ComboMouseListener() );
    //===================================================================================
    * Set items for ButtonsCombo in the specified array
    public void setItems ( Object [] items ) {
    setModel ( new DefaultComboBoxModel( items ) );
    //```````````````````````````````````````````````````````````````````````````````````
    * Set items for ButtonsCombo in the specified Vector
    public void setItems ( Vector items ) {
    setModel ( new DefaultComboBoxModel( items ) );
    //```````````````````````````````````````````````````````````````````````````````````
    * Get current items in a array
    public Object [] getItemsArray () {
    ComboBoxModel model = this.getModel ();
    if ( model != null ) {
    int size = model.getSize ();
    if ( size > 0 ) {
    Object [] items = new Object[ size ];
    for ( int i = 0; i < size; i++ ) {
    items[ i ] = model.getElementAt ( i );
    return items;
    return null;
    //```````````````````````````````````````````````````````````````````````````````````
    * Get current items in a Vector
    public Vector getItemsVector () {
    ComboBoxModel model = this.getModel ();
    if ( model != null ) {
    int size = model.getSize ();
    if ( size > 0 ) {
    Vector itemsVec = new Vector();
    for ( int i = 0; i < size; i++ ) {
    itemsVec.addElement ( model.getElementAt ( i ) );
    return itemsVec;
    return null;
    //===================================================================================
    class ComboMouseListener extends MouseAdapter {
    public void mouseClicked ( MouseEvent me ) {
    ButtonsCombo.this.hidePopup ();
    public void mousePressed ( MouseEvent me ) {
    ButtonsCombo.this.hidePopup ();
    ButtonsCombo.this.setBorder ( BorderFactory.createBevelBorder ( BevelBorder.LOWERED ) );
    public void mouseReleased ( MouseEvent me ) {
    ButtonsCombo.this.hidePopup ();
    ButtonsCombo.this.setBorder ( BorderFactory.createBevelBorder ( BevelBorder.RAISED ) );
    //===================================================================================
    class ComboRenderer extends JLabel implements ListCellRenderer {
    //````````````````````````````````````````````````
    public ComboRenderer () {
    setOpaque ( true );
    //````````````````````````````````````````````````
    public Component getListCellRendererComponent ( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
    setBackground ( isSelected ? Color.cyan : Color.white );
    setForeground ( isSelected ? Color.red : Color.black );
    setText ( ( String )value );
    return this;
    //````````````````````````````````````````````````
    //===================================================================================
    // We have to use this class, otherwise we cannot stop JComboBox's popup to go down
    class ComboUI extends BasicComboBoxUI {
    public JButton createArrowButton () throws NullPointerException {
    try {
    URL url = getClass ().getResource ( "/images/comboarrow.gif" );
    JButton b = new JButton( new ImageIcon( url ) );
    b.addActionListener ( new ActionListener() {
    public void actionPerformed ( ActionEvent ae ) {
    return b;
    } catch ( NullPointerException npe ) {
    throw new NullPointerException( "/images/comboarrow.gif not found or /images folder not in classpath" );
    catch ( Exception e ) {
    e.printStackTrace ();
    return null;
    //======================================================================
    you can cutomize this according to your requirement , okie ;)

  • I have 9.0.1 on 2 pc's, both xp sp3. On 1 the 'open new tab' button is visible, on the other, the 'open new tab' button is not even available in the 'customize toolbar' menu for dragging and dropping. Why?

    I used the same installation file, but on 1 pc, the 'open new tab' button is available in the 'customize toolbar' menu and can be dragged and dropped onto the navigation bar. On the other pc, the 'open new tab' button/icon is not even available for dragging and dropping. I uninstalled firefox completely, including settings and preferences, then reinstalled, but that did not correct the missing button.

    Hi,
    Please try '''Restore Default Set''' in the '''Customize...''' window. If it's still not visible, one reason could be that the button is already placed on the toolbar but may be hidden behind another icon or toolbar.
    Useful links:
    [https://support.mozilla.com/en-US/kb/Options%20window All about Tools > Options]
    [http://kb.mozillazine.org/About:config Going beyond Tools > Options - about:config]
    [http://kb.mozillazine.org/About:config_entries about:config Entries]
    [https://support.mozilla.com/en-US/kb/Page%20Info%20window Page Info] Tools (Alt + T) > Page Info, Right-click > View Page Info
    [https://support.mozilla.com/en-US/kb/Keyboard%20shortcuts Keyboard Shortcuts]
    [https://support.mozilla.com/en-US/kb/Viewing%20video%20in%20Firefox%20without%20a%20plugin Viewing Video without Plugins]
    [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder & Files]
    [https://developer.mozilla.org/en/Command_Line_Options#Browser Firefox Commands]
    [https://support.mozilla.com/en-US/kb/Basic%20Troubleshooting Basic Troubleshooting]
    [https://support.mozilla.com/en-US/kb/common-questions-after-upgrading-firefox-36 After Upgrading]
    [https://support.mozilla.com/en-US/kb/Safe%20Mode Safe Mode]
    [http://kb.mozillazine.org/Problematic_extensions Problematic Extensions]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20extensions%20and%20themes Troubleshooting Extensions and Themes]
    [https://support.mozilla.com/en-US/kb/Troubleshooting%20plugins Troubleshooting Plugins]
    [http://kb.mozillazine.org/Testing_plugins Testing Plugins]

  • In the spry css menu, how do i know what does what?

    I have two questions,
    (1)    In the spry css menu, is it just a case of trial and error to find out what each one does or is there a recognisable freature of each line to tell me what each one does, there are so many of them and most of them are alike. I cant help thinking there is a simple way of identifying what each one does without having to search around in the dark until i stumble on the right one that dose what i am trying to tweak in the appearance of the menu bar.
    (2)  When I am inserting the data for each of the navigation links when i first insert the spry menu I.E.... HOME...ABOUT...COURSES....CONTACT  and the list items under "COURSES" link successfully to each page when clicked in the browser. When i click the "HOME" button, a drop down menu of the navigation options ( HOME...ABOUT...COURSES...CONTACT) appears under it. How do I eliminate this when i insert the spry menu bar so it does not appear in the browser.

    Have a look here http://www.dwcourse.com/dreamweaver/ten-commandments-spry-menubars.php#one
    Have proper markup.
    Although the above are true answers to your questions, I have reason to believe that it will not satisfy you. Remember that these are user to user forums and that we do not have much time to spare. We can answer most specific questions, but do not have the time to answer generic questions to their fullest extent.
    What I am trying to say is, please supply a link to your site with a specific question and we will help where we can.
    Gramps

  • How do I get Yahoo off the right click menu where I am searching a hi-lighted word?

    If I hi-lite a word then right click the drop down menu says search Yahoo for...
    I don't like Yahoo and don't want it on my browser.
    I would like to use a search engine of my own choosing.
    Thanks.

    That item in the right-click context menu uses the default search engine as set in the search bar on the Navigation Toolbar.
    *https://support.mozilla.org/kb/Search+bar

  • Navigating the site near impossible

    The site is impossible to navigate. I am looking for discussions, questions posted in different SAP modules and I can't find a way to navigate from one module to another. How do I find the discussion board for Enterprise asset management or PP (Production planning) from the start page?  This is truly baffling me

    Hi,
    I also find it pretty frustrating when it comes to navigating the site but I realize that SAP has so many products which why they not have been able to organize it in the most intuitive way. But the following screen shots should give you a general direction, though.
    When you go to http://scn.sap.com
    Click on Products, a drop down menu will expand, here you will find pretty much every forum.
    For example, EAM space
    Its sub-space EAM below:
    ERP space and when you click on it you will see it's sub-spaces like Production Planning etc (below):
    If you want to go to ABAP, it's little bit tedious (which is why you may want to book mark it if you visit it frequently)
    Business intelligence forums (or Spaces as SAP likes to call 'em)

  • Add custom command in the context KM menu

    Hello All,
    Wanna know if its possible to add custom command in the KM context menu?
    If yes, please guide as to how can I do this....
    Example: Print option in the context menu
    Awaiting Reply.
    Thanks & Warm Regards,
    Ritu

    Hi Ritu,
       Yes, you can do that.
       First of all, you should identify the layout set that you are using. If you do not know it you can enable debugging setting option.
       Then, you must know where you need to appear this command. I mean, in a folder, link or document.
       If you are using a standard layout you should not modify it, you must duplicate it (you ca use advance copy).
      The command must be added in a group command, you can use an exist command or create a new one. (System Administration-System Configuration-KM-CM-User Interface-Command Groups). Before that you can create your command.
    These groups are referenced from collection and resource renderer. A layout set is a set of collection and resource rendeders.
    You should read this link.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/98/dd48a9b4a197489a54187c99372bce/frameset.htm
    Once you added your comamnd a group and assign this group in your collection or resource renderer. You have to assign this layout to your km navigation iview or directly the folder.
    Don't forget to enable presentation service in your repository in order to change the layout.
    Patricio.

  • Top Navigation Bar drop down menu's do not work

    Top Navigation Bar drop down menu's do not work. It is only happening on a couple of my site collections and is affecting on the main page of those collections. There is only one web part on the main page, it is the Picture Library Slideshow web part. When
    I remove that web part, the menu's come back and work with no problem. I re-add the web part and the menu's stop working. Not finding any error's in the server logs, there are no visual error's thrown.  Any advice on what might be happening? I've checked
    the Java update on our computers and it has the latest version.  Open to any advice at this point.
    DA
    ~~~~~~~~~ DAnderson

    Hi,
    How does the Top Navigation Bar dropdown menu issue look like?
    Could you please provide a screenshot about the issue, also may detecte the problematic elements by using IE browser developer tool (keyboard F12)?
    Please also check if it is related IE compatibility issue.
    Thanks
    Daniel Yang
    TechNet Community Support

  • Where can I find the phone menu icon used in the sample flyout menu tutorial?

    Where can I find the phone menu icon used in the Muse phone menu flyout tutorial?
    It is a .little box with an arrow on te left and three lines center/right.

    Hi
    You can use the ones in Muse library :
    http://muse.adobe.com/exchange-library/amphi-navigation-bars-by-qooqee-com-ali-pordeli
    http://muse.adobe.com/exchange-library/harmony-animated-menu
    Thanks,
    Sanjit

Maybe you are looking for

  • How do I restrict use of mac mini to one website only?

    Hi Geniuses! I want to set up a Mac Mini in my office that can only be used to browse 1 website and nothing else. I don't want any user other than Admin to have the ability to change any settings, download any apps, install any software or browse the

  • SEEBURGER AS2: AS2 Adapter failure -- CryptoApiException: Access Denied.

    Hi, I am trying to send AS2 message to my partner by using Certificates and I am getting the following error at AS2 receiver adapter.Looks like it doesn't have User Credentials to access the certificates.But we provided all the details.We are not sur

  • What is the disadvantage of using hints in query

    hi all, i am report developer, in my project we were using hits in the query ... so that the query performance has improved .. my question is if we use hints in the query will it give any effects.. means to say instead of using hints we can make use

  • The Simplest way to record acoustic guitar/vocals

    I'm no musician, but I have a MBP C2D and I want to record my grandpa playing guitar and singing with GB. He won't be around forever and all I want to do is preserve some of his music for our family. Can someone please tell me what I need to acomplis

  • Table or conbination of tables having Fields BUKRS and EKORG

    Hi Can you please help me out in finding out a table in SRM having fields BUKRS ( company code) and EKORG (purchasing organization ) so that i can fetch the vendors with the above selection . It can be a combination of tables also .