NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

package assignment;

import java.io.*;
import java.sql.*;
import java.util.*;

abstract class Employee
{
static int count=0;
int ID;
String name;
int age;
double salary;
String designation;
Employee()
{
count++;
/*Scanner sc = new Scanner(System.in);

System.out.print("nEnter name : ");
name = sc.next();
do
{
try
{
System.out.print("nEnter age : ");
age = new Scanner(System.in).nextInt();
}
catch(InputMismatchException ime)
{
System.out.println("Enter valid age");
}
if(age<=21 || age>=60)
System.out.println("Please enter age between 21 to 60");
else
return;
}while(true);*/

try
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","tiger");

PreparedStatement pstmt = con.prepareStatement("insert into Emp values(?,?)");

for(int i=1; i<=10; i++)
{
System.out.print("nEnter ID: ");
int ID = Integer.parseInt(br.readLine());
System.out.print("nEnter name: ");
String name = br.readLine();
System.out.print("Enter age: ");
int age = Integer.parseInt(br.readLine());

pstmt.setInt(1,ID);
pstmt.setString(2,name);
pstmt.setInt(3,age);
pstmt.execute();

}

pstmt.close();
con.close();

}
catch(Exception e)
{
System.out.println(e);
}

}

public abstract void raiseSalary();
}

final class Clerk extends Employee
{
Clerk()
{
salary=8000;
designation="Clerk";
}
public void raiseSalary()
{
salary+=2000;
}
}

final class Programmer extends Employee
{
Programmer()
{
salary=25000;
designation="Programmer";
}
public void raiseSalary()
{
salary+=5000;
}
}

final class Manager extends Employee
{
Manager()
{
salary=70000;
designation="Manager";
}
public void raiseSalary()
{
salary+=10000;
}
}
public class EmployeeMain
{
public static void main(String args[])
{
int ch1=0, ch2=0;
LinkedList<Employee> e = new LinkedList<Employee>();
do
{
System.out.println("===============");
System.out.println("1. Create");
System.out.println("2. Display");
System.out.println("3. Raise Salary");
System.out.println("4. Delete");
System.out.println("5. Exit");
System.out.println("===============");
try
{
System.out.print("Enter choice:- ");
ch1 = new Scanner(System.in).nextInt();
if(ch1==1)
{
do
{
System.out.println("===============");
System.out.println("1. Clerk");
System.out.println("2. Programmer");
System.out.println("3. Manager");
System.out.println("4. Exit");
System.out.println("===============");
try
{
System.out.print("Enter choice:- ");
ch2 = new Scanner(System.in).nextInt();
switch(ch2)
{
case 1:e.add(new Clerk());
break;
case 2:e.add(new Programmer());
break;
case 3:e.add(new Manager());
break;
}
}
catch(InputMismatchException ime2)
{
System.out.println("Please enter choice between 1 and 4");
}
}while(ch2!=4);
}
if(ch1==2)
{
Iterator i = e.iterator();
while(i.hasNext())
{
System.out.println(i.next());

}

}
if(ch1==3)
{
Iterator j = e.iterator();
while(j.hasNext())
{
Employee e1 = (Employee)j.next();
e1.raiseSalary();
System.out.println(e1);

}
}
if(ch1==4)
{

}
}
catch(InputMismatchException ime3)
{

System.out.println("Please enter choice between 1 and 4");
}

}while(ch1!=5);

System.out.println("nnTotal no. of employees created: "+Employee.count);
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.