0% found this document useful (0 votes)
33 views1 page

Sample Mobile

The document is a Java program that manages a list of students, allowing input of their details and searching for a student by ID. It creates an array of Student objects, reads their attributes from user input, and then finds the student with the maximum age and a specific student by ID. The program outputs the details of the found students or a message if no student is found.

Uploaded by

liseyar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views1 page

Sample Mobile

The document is a Java program that manages a list of students, allowing input of their details and searching for a student by ID. It creates an array of Student objects, reads their attributes from user input, and then finds the student with the maximum age and a specific student by ID. The program outputs the details of the found students or a message if no student is found.

Uploaded by

liseyar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package mobile;

import java.util.Scanner;
public class Solution {
public static void main(String[] args) {

Student[] students=new Student[4];


Scanner sc=new Scanner(System.in);
int in=sc.nextInt();sc.nextLine();
for(int i=0;i<in;i++){
int a=sc.nextInt();sc.nextLine();
String b=sc.nextLine();
int c=sc.nextInt();sc.nextLine();
int d=sc.nextInt();sc.nextInt();
students[i]=new Student(a,b,c,d);

}
int input1=sc.nextInt();sc.nextLine();
Student res1=findStudentWithMaximumAge(students);
System.out.println("id-"+res1.id);
System.out.println("name-"+res1.name);
System.out.println("marks-"+res1.marks);
System.out.println("age-"+res1.age);

Student res2=searchStudentById(students,input1);
if(res2==null)
{
System.out.println("no Students found with mention attribute");

}
else
{
System.out.println("id-"+res2.id);
System.out.println("name-"+res2.name);

You might also like