Java program to sort ten numbers using bubble sort method

Q. Write a java program to sort ten numbers using bubble sort method.

Ans. class Bubble sort

            {

             Public static void main (string arts [] throws Io Exception

           {

            Buffered Reader in=new buffered reader (new input stream reader (system. in) ;

           Int num [];

          Num=new Int [10];

          Int I;

          String number;

          System.out.printIn ("Enter 10 numbers");

          For (I=0; i<10; i++)

         {

             Number=in. Read Line ();

             Number [I] = Integer.parseInt (number);

        }

        System.out.println ("you have entered");

        For (I=0; I<10; I++)

        {

       System.out.print (" " + num[I]+" ");

       }

     \\ Sorting beings here

    For (I=0; I <10; I++)

{

      For (J=0; J < 9-I; J++)

     {

         If (num [J] > num [J+I])

        {

           Temp= num [J];

           Num [J] = num [J+1];

            Num [J+1] = temp;

       }

  }

}

System.out.println ("array after sorting");

For (I=0; I<10; I++) \\ loop

{

       System.out.print ("  " + num [I] +" " );

} \\ end loop

} \\ end main

} \\end class

   Related Questions in Programming Languages

  • Q : Explain Abstract Windowing Toolkit

    Abstract Windowing Toolkit: The Abstract Windowing Toolkit (AWT) offers a collection of classes which simplify the creation of applications with the GUI (graphical user interfaces). Such are to be found in the java.awt packages. Included are classes f

  • Q : Create a BottomUpTwoThreeFourTree class

    You will need to create a BottomUpTwoThreeFourTree class, with a BottomUpTwoThreeTreeFourTree constructor which keeps no parameters. BottomUpTwoThreeTreeFourTree will require an insert(int x) method, which will insert the value 

  • Q : Differences between XHTML and HTML

    Explain the differences between XHTML and HTML?

  • Q : State the term GPC and GPT State the

    State the term GPC and GPT.

  • Q : Explain Assignment operator Assignment

    Assignment operator: The operator (=) employed to store the value of an expression into the variable, for example: Variable = expression; The right-hand

  • Q : Use the Alice Program Use the Alice

    Use the Alice Program from the link below to complete and save the five projects . http://alice.org/ (should be Alice 2.2 or newer) Assignment 1

    Q : UK assignment & homework help Need UK

    Need UK Assignment Help, UK Homework Help. Get it now! HwA provides email based and live UK assignment help and UK homework help in a variety of subjects to the students based out

  • Q : Define Object-oriented language

    Object-oriented language: Programming languages like Java and C++ which permit the solution to a trouble to be stated in terms of objects that belong to the classes.

  • Q : Examples for 8 -16 - 32 bit

    Normal 0 false false

  • Q : Advantages of Object oriented

    Q. What are the advantages of Object Oriented Programming languages? Explain them. Ans. : Object oriented programming language has following advantages-

    Discover Q & A

    Leading Solution Library
    Avail More Than 1439695 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering

    18,76,764

    1933838
    Asked

    3,689

    Active Tutors

    1439695

    Questions
    Answered

    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.