Experiment 6 24
Experiment 6 24
{
int IdNo,phy,chem,maths,n,total; String name;
public Student(int id,String n,int m,int p,int c,int t)
{
IdNo=id;
name=n;
maths=m;
phy=p; chem=c;
total=t;
}
public static void main(String args[])
{
int IdNo,phy,chem,maths,n,total;
String name;
Student s[];
Scanner sc=new Scanner(System.in);
System.out.println("Enter number of Students:");
n=sc.nextInt();
s=new Student[n];
Object Oriented Programming using Java Laboratory (DJS23FLES201)
Academic Year 2024-25
}
System.out.println("Record of the Students as per Descending order of total marks: ");
for(int i=0;i<s.length-1;i++)
{ for(int j=0;j<s.length-1-
i;j++)
{ if(s[j].total <
s[j+1].total)
{
Student temp;
temp=s[j]; s[j]=s[j+1];
s[j+1]=temp;
}
}
}
System.out.println("ID Number\tName\tMaths\tPhysics\tChemistry\tTotalMarks");
for(int i=0;i<s.length;i++)
{
System.out.print(s[i].IdNo+"\t\t"+s[i].name+"\t"+s[i].maths+"\t"+s[i].phy+"\t"+s[i].chem+"\t\t"+s[i].t
otal);
Object Oriented Programming using Java Laboratory (DJS23FLES201)
Academic Year 2024-25
System.out.println();
}
}}
Output:
Code:
class Complex {
double real;
double imaginary;
System.out.println("Sum:");
sum.display();
System.out.println("Difference:");
difference.display();
System.out.println("Product:");
product.display();
}
}
Output: