U3p7.java

import java.util.*; class u2p7 { public static void main(String[] args) { String name[]=new String[5]; int marks[]=new int[5]; Scanner sc=new Scanner(System.in); System.out.println("Enter name and marks(1-100):"); for(int i=0;i<5;i++) { name[i]=sc.next(); marks[i]=sc.nextInt(); } for(int i=0;i<5;i++) { System.out.println("name="+name[i]); System.out.println("marks="+marks[i]); } System.out.println("Sorted List"); for(int i=0; i<5; i++) { for(int j=i+1; j<5; j++) { if(marks[i] < marks[j]) { int temp = marks[i]; String nam=name[i]; marks[i] = marks[j]; name[i]=name[j]; marks[j] = temp; name[j]=nam; } } System.out.println("marks"+" "+"names\n"+" "); System.out.println(marks[i]+" "+name[i]); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.