#7,#8 2998
#7,#8 2998
#7,#8 2998
AIM: Create a menu based Java application with the following options.1.Add an
Employee2.Display All3.Exit If option 1 is selected, the application should gather details of
the employee like employee name, employee id, designation and salary and store it in a file.
If option 2 is selected, the application should display all the employee details. If option 3 is
selected the application should exit.
SOURCE CODE:
import java.util.*;
import javax.swing.plaf.synth.SynthSplitPaneUI;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.Serializable;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
public class emplll implements Serializable{
static void adde(){
try{
String s=new String();
File file=new File("D:\\emp.txt");
FileOutputStream fout=new FileOutputStream("D:\\emp.txt",true);
System.out.println("Enter the employee name");
Scanner in=new Scanner(System.in);
s=in.nextLine();
s=s+" ";
byte b[]=s.getBytes();
fout.write(b);
System.out.println("Enter the employee id");
s=in.nextLine();
s=s+" ";
b=s.getBytes();
fout.write(b);
System.out.println("Enter the employee designation");
s=in.nextLine();
s=s+" ";
b=s.getBytes();
fout.write(b);
System.out.println("Enter the employee salary");
s=in.nextLine();
s=s+"\n";
b=s.getBytes();
fout.write(b);
fout.close();
System.out.println("success...");
}catch(Exception e){System.out.println(e);}
}
static void display(){
try{
FileInputStream fin=new FileInputStream("D:\\emp.txt");
int i=0;
while((i=fin.read())!=-1){
System.out.print((char)i);
}
fin.close();
}catch(Exception e){System.out.println(e);}
}
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n;
int x=1;
do{
System.out.println("1. Add Employee");
System.out.println("2. Display all");
System.out.println("3. Exit");
x=in.nextInt();
break;
}
case 2:{
display();
System.out.println("do you want to continue\n1 for yes\n2 for no");
x=in.nextInt();
break;
}
case 3:{
System.exit(0);
}
default:{
System.out.println("Invalid Input");
System.out.println("\ndo you want to continue\n1 for yes\n2 for no");
x=in.nextInt();
break;
}
}
}while(x==1);
}
}
SCREENSHOTS :
EXPERIMENT 8
1. AIM: Create a palindrome creator application for making a longest possible palindrome out
of given input string.