Computer Science, asked by nishu1205, 8 months ago

write a java program to input name and percentage of 35 students in two separate single dimensional arrays. Arrange student details according to thier percentage in descending order using bubble sort method. Display the name and percentage of first ten toppers of the class​

Answers

Answered by keyboardavro
8

Answer:

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

}

}

}

Explanation:

Answered by srivastavaaryaman0
0

Answer:

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

}

}

}

Explanation:

Similar questions