Java Lab 5-6
Java Lab 5-6
Program:
import java.io.*;
class Complex{
double real = 0;
double im = 0;
Complex(){
//real = 5;
//im = 3;
real = r;
im = i;
Complex(Complex obj){
real = obj.real;
im = obj.im;
double i = im + num.im;
double i = im - num.im;
class day5 {
throws IOException{
while (true){
System.out.print("\nEnter
choice:\nDefault\nParameterized\nCopy\nExit\n->");
if (ch1.equals("default")){
else if (ch1.equals("parameterized")){
Double n1 = Double.parseDouble(reader.readLine());
System.out.print("Imagninary: ");
Double n2 = Double.parseDouble(reader.readLine());
Double n3 = Double.parseDouble(reader.readLine());
System.out.print("Imagninary: ");
Double n4 = Double.parseDouble(reader.readLine());
else if (ch1.equals("copy")){
Double n1 = Double.parseDouble(reader.readLine());
System.out.print("Imagninary: ");
Double n2 = Double.parseDouble(reader.readLine());
else if (ch1.equals("exit")){
break;
else
}
Output:
NETAJI SUBHASH ENGINEERING COLLEGE
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND MACHINE
LEARNING
Average Marks
Problem Statement: Write a program to maintain the office database using
inheritance. Superclass is Employee that contains the information as follows:
Emp_code, Emp_name, Address, Ph_no, Da=10%, Hra=20%. The inheritance
properties held by the problem is as follows:
Program:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Employee{
int emp_code;
String emp_name;
String address;
String phone_no;
Double da=0.1;
Double hra=0.2;
int basic_pay;
emp_code = code;
emp_name = name;
address = ad;
phone_no = phone;
da += increase;
hra += increase;
void show_da_hra(){
basic_pay = pay;
void show_salary(){
void show_details(){
System.out.println("\nEmployee Details:-");
System.out.println("----------------");
String subject_specialization;
String designation;
Teaching(int code, String name, String ad, String phone, String subject, String
desig){
subject_specialization = subject;
designation = desig;
designation = desig;
String position;
Office(int code, String name, String ad, String phone, String pos){
position = pos;
position = pos;
String research_area;
Faculty(int code, String name, String ad, String phone, String subject, String
desig, String research){
research_area = research;
void show_more_details(){
String tech_expert_area;
Technical(int code, String name, String ad, String phone, String subject, String
desig, String tech){
tech_expert_area = tech;
void show_more_details(){
Administrative(int code, String name, String ad, String phone, String pos){
void show_more_details(){
Accounts(int code, String name, String ad, String phone, String pos){
void show_more_details(){
class day6 {
throws IOException{
while (true){
System.out.print("Enter
department:\nfaculty\ntechnical\nadministrative\naccounts\n->");
String ch = reader.readLine();
if (ch.equals("faculty")){
emp.set_basic_pay(pay);
emp.show_details();
emp.show_more_details();
emp.show_salary();
else if (ch.equals("technical")){
emp.set_basic_pay(pay);
emp.show_details();
emp.show_more_details();
emp.show_salary();
else if (ch.equals("administrative")){
emp.set_basic_pay(pay);
emp.show_details();
emp.show_more_details();
emp.show_salary();
else if (ch.equals("accounts")){
emp.set_basic_pay(pay);
emp.show_details();
emp.show_more_details();
emp.show_salary();
else{
System.out.println("\n");
continue;
if (exit.equals("y")){
break;
}
Output: