0% found this document useful (0 votes)
40 views

Import Java - Io. Import Java - Util.Arraylist Import Java - Util.Iterator Import Java - Util.Scanner Public Class Main (

The document defines classes for processing applicant details. It takes applicant information as input, stores it in an ArrayList, writes the ArrayList to a file, reads it back and then evaluates if applicants are eligible for a job based on their CGPA, representation at country/state level and position secured. It first takes applicant details like name, age, program, CGPA etc as input, creates ApplicantDetails objects, adds to an ArrayList and writes to a file. It then reads from this file, iterates through applicants and checks eligibility criteria to print if they are eligible or not.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Import Java - Io. Import Java - Util.Arraylist Import Java - Util.Iterator Import Java - Util.Scanner Public Class Main (

The document defines classes for processing applicant details. It takes applicant information as input, stores it in an ArrayList, writes the ArrayList to a file, reads it back and then evaluates if applicants are eligible for a job based on their CGPA, representation at country/state level and position secured. It first takes applicant details like name, age, program, CGPA etc as input, creates ApplicantDetails objects, adds to an ArrayList and writes to a file. It then reads from this file, iterates through applicants and checks eligibility criteria to print if they are eligible or not.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.io.

*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

public static void main(String[] args) throws IOException {


Scanner scanner=new Scanner(System.in);
System.out.println("Enter the number of applicants: ");
int n=scanner.nextInt();
scanner.nextLine();
ArrayList<ApplicantDetails> array=new ArrayList<>();
for (int i=0;i<n;i++){
String name= scanner.nextLine();
int age=scanner.nextInt();
scanner.nextLine();
String prog=scanner.nextLine();
float cgpa=scanner.nextFloat();
scanner.nextLine();
String uni=scanner.nextLine();
boolean repCon= scanner.nextBoolean();
boolean repSta=scanner.nextBoolean();
ApplicantDetails applicantDetails=new
ApplicantDetails(name,age,prog,cgpa,uni,repCon,repSta);
array.add(applicantDetails);

}
try {
FileOutputStream fos = new FileOutputStream("inputMID.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);

oos.writeObject(array);
oos.close();
fos.close();
System.out.println("Successfully written in file.");
}catch (IOException io){
io.printStackTrace();
}
array.clear();
FileInputStream fis=new FileInputStream("inputMID.txt");
ObjectInputStream ois=new ObjectInputStream(fis);
try {
array=(ArrayList<ApplicantDetails>)ois.readObject();

} catch (ClassNotFoundException e) {
e.printStackTrace();
}

Iterator<ApplicantDetails> itr=array.iterator();
while (itr.hasNext()){
ApplicantDetails a=itr.next();
if ((a.getCGPA()>5.0 && a.represented_country) || (a.getCGPA()>5 &&
a.represented_state && a.representedStatePosition<=3)){
System.out.println("YOU ARE ELIGIBLE FOR THE JOB.");
}else {
System.out.println("YOU ARE NOT ELIGIBLE FOR THE JOB.");
}
}
}
}

ApplicantDetails.java
import java.util.Scanner;

public class ApplicantDetails {


String name;
int age;
String programme;
float CGPA;
String uni_name;
boolean represented_country;
boolean represented_state;
int representedStatePosition;
String game_name;
Scanner scanner=new Scanner(System.in);

public ApplicantDetails(String name, int age, String programme, float CGPA,


String uni_name, boolean represented_country, boolean represented_state) {
this.name = name;
this.age = age;
this.programme = programme;
this.CGPA = CGPA;
this.uni_name = uni_name;
this.represented_country = represented_country;
this.represented_state = represented_state;
setRepresentedStatePositionAndGameName();
}

public void setRepresentedStatePositionAndGameName(){


if (!this.represented_state){
this.representedStatePosition=0;
if (!this.represented_country){
this.game_name=null;
}else {
System.out.println("Enter the name of game: ");
this.game_name=scanner.nextLine();
}
}else{
System.out.println("Enter the position secured in state: ");
this.representedStatePosition=scanner.nextInt();
scanner.nextLine();
System.out.println("Enter the game name: ");
this.game_name=scanner.nextLine();
}
}

public String getName() {


return name;
}

public int getAge() {


return age;
}

public String getProgramme() {


return programme;
}

public float getCGPA() {


return CGPA;
}

public String getUni_name() {


return uni_name;
}

public boolean isRepresented_country() {


return represented_country;
}

public boolean isRepresented_state() {


return represented_state;
}

public int getRepresentedStatePosition() {


return representedStatePosition;
}

public String getGame_name() {


return game_name;
}
}

You might also like