0% found this document useful (0 votes)
14 views11 pages

Oopjava Ex4&5

The document describes two Java applications: one for generating Staff and Student Subject Reports and another for generating payslips using inheritance. The first application collects data for teachers and college students, displaying their information, while the second application allows users to input employee details and calculate payslips for different roles such as Developer, Manager, Designer, and Accountant. Both programs were successfully implemented and executed.

Uploaded by

seellasrihari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views11 pages

Oopjava Ex4&5

The document describes two Java applications: one for generating Staff and Student Subject Reports and another for generating payslips using inheritance. The first application collects data for teachers and college students, displaying their information, while the second application allows users to input employee details and calculate payslips for different roles such as Developer, Manager, Designer, and Accountant. Both programs were successfully implemented and executed.

Uploaded by

seellasrihari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

EX NO : 4 Implementation of High School Application

AIM
To develop a Java application to generate Staff and Student Subject Report.

PROGRAM

import java.util.Scanner;
class Person
{
Scanner input=new Scanner(System.in);
int age;
String Name;
String gender;
void getdatap()
{
System.out.println("Enter age,name,gender");
age =input.nextInt();
input.nextLine();
Name=input.nextLine();
gender =input.nextLine();
}}
class Student extends Person
{
int regno;
double CGPA;
String dept;
void getdatas()
{
System.out.println("Enter reg_no. ,CGPA,department of student: ");
regno =input.nextInt();
CGPA=input.nextDouble();
input.nextLine();
dept =input.nextLine();
}}
class Teacher extends Person
{
int Salary;
String Subject;
void getdatat()
{
System.out.println("enter salary,subject of teacher");
Salary =input.nextInt();
input.nextLine();
Subject=input.nextLine();
}
void displayt()
{
System.out.println("Teacher's info: ");
System.out.println("Age of teacher is "+age);
System.out.println("Name of teacheris "+Name);
System.out.println("Gender of teacher is "+gender);
System.out.println("Salary is "+Salary);
System.out.println("Subject is "+Subject);
}}
class CollegeStudent extends Student
{
String majors;
int Currentyear;
void getdatacs()
{
System.out.println("Enter major subject and Current year of college student: ");
majors=input.nextLine();
Currentyear=input.nextInt();
}
void displaycs()
{
System.out.println("Students info: ");
System.out.println("Registration number is "+regno);
System.out.println("CGPA of student is "+CGPA);
System.out.println("Department of student is "+dept);
System.out.println("Major subject is"+majors);
System.out.println("Current year is "+Currentyear);
}
}
public class JavaApplication{
public static void main(String[] args)
{
Teacher t=new Teacher();
t.getdatap();
t.getdatat();
CollegeStudent s=new CollegeStudent();
s.getdatas();
s.getdatacs();
t.displayt();
System.out.println("********************");
s.displaycs();
}}

OUTPUT
Enter age,name,gender
18
Julie
Female
enter salary,subject of teacher
100000
Java
Enter reg_no. ,CGPA,department of student:
258963147
9.5
Computing
Enter major subject and Current year of college student:
OOP Through Java
2023
Teacher's info:
Age of teacher is 18
Name of teacheris Julie
Gender of teacher is Female
Salary is 100000
Subject is Java
********************
Students info:
Registration number is 258963147
CGPA of student is 9.5
Department of student is Computing
Major subject is OOP Through Java
Current year is 2023

RESULT
Thus the java program to generate Staff and Student Subject Report was implemented and executed
successfully
EX NO : 5 PROGRAM TO GENERATE PAYSLIP USING
INHERITANCE
AIM
To develop a Java application to generate payslip using inheritance.

PROGRAM
import java.util.*;
class employee
{
int empid;
long mobile;
String name, address, email;
Scanner get = new Scanner(System.in);
void getdata()
{
System.out.print("Enter Name of the Employee: ");
name = get.nextLine();
System.out.print("Enter Employee E-mail id: ");
email = get.nextLine();
System.out.print("Enter Address of the Employee: ");
address = get.nextLine();
System.out.print("Enter Employee id: ");
empid = get.nextInt();
System.out.print("Enter Mobile Number: ");
mobile = get.nextLong();
}
void display()
{
System.out.println("************************************************");
System.out.println("Employee Information");
System.out.println("************************************************");
System.out.println("Employee Name: "+name);
System.out.println("Employee id: "+empid);
System.out.println("Mail id: "+email);
System.out.println("Address: "+address);
System.out.println("Mobile Number: "+mobile);
System.out.println("\n");
}
}
class developer extends employee
{
double salary, bp, da, hra, pf, ta, net, gross;
void getdeveloper()
{
System.out.print("Enter Your Basic pay: ");
bp = get.nextDouble();
}
void calculatedev()
{
da=(0.15*bp);
hra=(0.20*bp);
pf=(0.12*bp);
ta=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-ta);
System.out.println("************************************************");
System.out.println("PAY SLIP FOR Developer");
System.out.println("************************************************");
System.out.println("Basic Pay:Rs"+bp);
System.out.println("DA:Rs"+da);
System.out.println("PF:Rs"+pf);
System.out.println("HRA:Rs"+hra);
System.out.println("ta:Rs"+ta);
System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);
}
}
class manager extends employee
{
double salary, bp, da, hra, pf, ta, net, gross;
void getmanage()
{
System.out.print("Enter Your Basic pay: ");
bp = get.nextDouble();
}
void calculatemng()
{
da=(0.15*bp);
hra=(0.20*bp);
pf=(0.12*bp);
ta=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-ta);
System.out.println("************************************************");
System.out.println("PAY SLIP FOR Manager");
System.out.println("************************************************");
System.out.println("Basic Pay:Rs"+bp);
System.out.println("DA:Rs"+da);
System.out.println("HRA:Rs"+hra);
System.out.println("PF:Rs"+pf);
System.out.println("ta:Rs"+ta);
System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);
}
}
class designer extends employee
{
double salary, bp, da, hra, pf, ta, net, gross;
void getdesign()
{
System.out.print("Enter Your Basic pay: ");
bp = get.nextDouble();
}
void calculatedesign()
{
da=(0.15*bp);
hra=(0.20*bp);
pf=(0.12*bp);
ta=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-ta);
System.out.println("************************************************");
System.out.println("PAY SLIP FOR Designer");
System.out.println("************************************************");
System.out.println("Basic Pay:Rs"+bp);
System.out.println("DA:Rs"+da);
System.out.println("HRA:Rs"+hra);
System.out.println("PF:Rs"+pf);
System.out.println("ta:Rs"+ta);
System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);
}
}
class accountant extends employee
{
double salary, bp, da, hra, pf, ta, net, gross;
void getaccountant()
{
System.out.print("Enter Your Basic pay: ");
bp = get.nextDouble();
}
void calculateaccountant()
{
da=(0.15*bp);
hra=(0.20*bp);
pf=(0.12*bp);
ta=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-ta);
System.out.println("************************************************");
System.out.println("PAY SLIP FOR Accountant");
System.out.println("************************************************");
System.out.println("Basic Pay:Rs"+bp);
System.out.println("DA:Rs"+da);
System.out.println("HRA:Rs"+hra);
System.out.println("PF:Rs"+pf);
System.out.println("ta:Rs"+ta);
System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);
}
}
class payslip
{
public static void main(String args[])
{
int choice,cont;
do
{
System.out.println("\n");
System.out.println("***** Welcome to MBU Payroll Management System *****");
System.out.println("\n");
System.out.println(" 1. Developer \t 2. Manager \t 3. Designer \t 4. Accountant");
Scanner c = new Scanner(System.in);
choice=c.nextInt();
switch(choice)
{
case 1:
{
developer dev=new developer();
dev.getdata();
dev.getdeveloper();
dev.display();
dev.calculatedev();
break;
}
case 2:
{
manager mng=new manager();
mng.getdata();
mng.getmanage();
mng.display();
mng.calculatemng();
break;
}
case 3:
{
designer design=new designer();
design.getdata();
design.getdesign();
design.display();
design.calculatedesign();
break;
}
case 4:
{
accountant acc=new accountant();
acc.getdata();
acc.getaccountant();
acc.display();
acc.calculateaccountant();
break;
}}
System.out.println("Do you want to quit press 0 to quit and press 1 to continue ");
cont=c.nextInt();
}while(cont==1);
}}

OUTPUT
Run:
***** Welcome to MBU Payroll Management System *****
1. Developer 2. Manager 3. Designer 4. Accountant
1
Enter Name of the Employee: Jane
Enter Employee E-mail id: [email protected]
Enter Address of the Employee: 103,vidyanagar,tirupati
Enter Employee id: 104
Enter Mobile Number: 9500711426
Enter Your Basic pay: 100000
************************************************
Employee Information
************************************************
Employee Name: Jane
Employee id: 104
Mail id: [email protected]
Address: 103,vidyanagar,tirupati
Mobile Number: 9500711426
************************************************
PAY SLIP FOR Developer
************************************************
Basic Pay:Rs100000.0
DA:Rs15000.0
PF:Rs12000.0
HRA:Rs20000.0
ta:Rs10000.0
GROSS PAY:Rs135000.0
NET PAY:Rs113000.0
Do you want to quit press 0 to quit and press 1 to continue

RESULT
Thus the java program to generate book information list was implemented and executed successfully

You might also like