Computer Science, asked by atanupal196133, 6 months ago

Write a program to input name and
percentage of N student of class-10 in two
separate one dimension arrays. Arrange
student’s details according to their
percentage in the descending order using
bubble sort method. Display name and
percentage of first ten topper of the class.

Answers

Answered by kmkrish2315
0

Answer:

Explanation:The program of the given question to display name and percentage of first ten toppers of the class is as follows:

import java.util.Scanner ; // created object called scanner

class School_Students // created class named School_Students

{

public static void main(String[] args)

{

String a[ ] = new String[35]; // variable string

int b[ ] = new int[35]; // variable integer

Scanner pin = new Scanner(System.in);

for (int i = 0; i < 35; i++) // loop

{

System.out.print("Enter the name of the student " + (i + 1) + " : "); // input from user is asked

a[i] = pin.nextLine();

System.out.print("Enter the percentage of the students : "); //input from user is asked

b[i] = pin.nextInt();

pin.nextLine();

}

int X=b.length;

for (int i=0; i<l-1; i++) // selection sort

{

int pop = i;

for (int j=i+1; j<l; j++)

{

if (b[j] > p[pop])

{

pop = j;

}

}

int X1 = b[pop];

b[pop] = b[i];

b[i] = X1; // percentage is swaped

String X2 = a[pop];

a[pop] = a[i];

a[i] = X2; // name is swaped

}

System.out.println("RANK \t NAME \t PERCENTAGE");

for (int i = 0; i < 10; i++)

{

System.out.println((i+1) + " \t " + a[i] + " \t " + b[i]); // top 10 students and their percentages are printed

}

}

}

Similar questions