Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Note: pLease do it using java programming language and also show the snap of out

ID: 3727087 • Letter: N

Question

Note: pLease do it using java programming language and also show the snap of output

Write a program to implement simple index on primary key for a file of employee records: 1. a. Implement addO to ask users to enter information about employee records, including their EID, Name, Age, and Rating, store these information to a fixed- length record file. Create an index file at the same time by using EID as primary key and RRN as reference (30 points). Implement search () by EID using the index file, and display the record on screen if record found, otherwise, display "Record not found!" (30 points) Extra bonus: implement delete () using the index file. (30 points). b. c.

Explanation / Answer

Source Code:-
================
package com.venkanna;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner;
class Employee
{
String EID;
String Name;
String age,rating;
Employee(String[] recordData)
{
this.EID=recordData[0];;
this.Name=recordData[1];;
this.age=recordData[2];
this.rating=recordData[3];
}
public String toString()
{
return "Record [id=" + EID + ", Name=" + Name + ", age="+ age + ", rating=" + rating + "]";
}
}
public class SimpleIndex
{
public static void main(String[] args) throws IOException
{
int EID;
String Name;
int age,rating;
Scanner sc=new Scanner(System.in);
String basePath = new File("").getAbsolutePath();
String recordPath = basePath.concat("/RecordList.txt");
FileWriter fw=new FileWriter("F:\Workspace_Luna\Challenging_Tasks\RecordList.txt");
System.out.println(recordPath + " ");
System.out.println("====================================");
System.out.println("*** Indexbased Employee Records ****");
System.out.println("====================================");
System.out.println("Please Enter Size of Records");
int size=sc.nextInt();
System.out.println("read "+size+" Records");
for(int i=0;i<size;i++)
{
System.out.println("Please Enter Employee EID");
EID=sc.nextInt();
System.out.println("Please Enter Employee Name");
Name=sc.next();
System.out.println("Please Enter Age:");
age=sc.nextInt();
System.out.println("Please Enter Rating/Salary");
rating=sc.nextInt();
try
{   
fw.write("#");
fw.write(EID+"|"+Name+"|"+age+"|"+rating);
fw.write("#");  
fw.write(" ");
}
catch(Exception e)
{
System.out.println(e);
}   
System.out.println("Successfully Stored all records");
}
LinkedList<Employee> recordArray = new LinkedList<Employee>();
System.out.println("*****************************");
System.out.println("All Records in File is");
try
{
BufferedReader file = new BufferedReader(new FileReader(recordPath));
String line;
String input = "";
while ((line = file.readLine()) != null)
{
input += line + ' ';
line = line.replaceFirst("#", "");
System.out.println(line);
String recordData[] = line.split("[|]");
Employee record = new Employee(recordData);
recordArray.add(record);
}
file.close();
}
catch (Exception e)
{
e.printStackTrace();
}
int flag=0,index=0;
System.out.println("Please Employee id to Search the Record");
String key=sc.next();
for(Employee obj:recordArray)
{
if(key.equals(obj.EID))
{
System.out.println(recordArray.get(index));
flag=1;
break;
}
index++;
}
if(flag!=1)
{
System.out.println("The Employee Details are not found");
}
System.out.println();
fw.close();
sc.close();
}
}

Sample Output:-
F:Workspace_LunaChallenging_Tasks/RecordList.txt
====================================
*** Indexbased Employee Records ****
====================================
Please Enter Size of Records
3
read 3 Records
Please Enter Employee EID
123
Please Enter Employee Name
venkanna
Please Enter Age:
25
Please Enter Rating/Salary
25000
Successfully Stored all records
Please Enter Employee EID
678
Please Enter Employee Name
Nari
Please Enter Age:
89
Please Enter Rating/Salary
5000
Successfully Stored all records
Please Enter Employee EID
987
Please Enter Employee Name
mani
Please Enter Age:
45
Please Enter Rating/Salary
32000
Successfully Stored all records
*****************************
All Records in File is
Please Employee id to Search the Record
900
The Employee Details are not found

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote