You are on page 1of 15

//*MODEL PROGRAM FOR STUDENT MARK LIST USING THE PARAMETER CONSTRUCTOR..........

1)PARAMETER CONSTRUCTOR

import java.io.*;

class studentmark

String name,d_no;

int tamil,english,maths,science,social;

studentmark(String a,String b,int c,int d,int e,int f,int g)

name=a;

d_no=b;

tamil=c;

english=d;

maths=e;

science=f;

social=g;

void display()

System.out.println("==========================================");

System.out.println("\t Student mark list details ");

System.out.println("==========================================");

System.out.println("std_Name="+name);

System.out.println("D_no="+d_no);

System.out.println("Tamil mark="+tamil);
System.out.println("English mark="+english);

System.out.println("Maths mark="+maths);

System.out.println("Science mark="+science);

System.out.println("Social mark="+social);

class studentmark1

public static void main(String args[])throws IOException

DataInputStream in=new DataInputStream(System.in);

String na,dno,grade;

int ta,en,ma,sc,so,tot;

double avg;

System.out.println("Enter the student name...");

na=in.readLine();

System.out.println("Enter the student D_no...");

dno=in.readLine();

System.out.println("Enter the Tamil mark...");

ta=Integer.parseInt(in.readLine());

System.out.println("Enter the English mark...");

en=Integer.parseInt(in.readLine());

System.out.println("Enter the Maths mark...");

ma=Integer.parseInt(in.readLine());
System.out.println("Enter the Science mark...");

sc=Integer.parseInt(in.readLine());

System.out.println("Enter the Social mark...");

so=Integer.parseInt(in.readLine());

tot=ta+en+ma+sc+so;

avg=tot/5;

if(avg>=90)

grade="a";

else if(avg>=50&&avg<=90)

grade="b";

else

grade="c";

studentmark s=new studentmark(na,dno,ta,en,ma,sc,so);

s.display();

System.out.println("Total mark="+tot);

System.out.println("Average is="+avg);

System.out.println("The Grade is="+grade);

System.out.println("=======================================");

OUTPUT:

Enter the student name...


sathish

Enter the student D_no...

111

Enter the Tamil mark...

88

Enter the English mark...

88

Enter the Maths mark...

88

Enter the Science mark...

88

Enter the Social mark...

88

==========================================

Student mark list details

==========================================

std_Name=sathish

D_no=111

Tamil mark=88

English mark=88

Maths mark=88

Science mark=88

Social mark=88

Total mark=440

Average is=88.0
The Grade is=b

D:\jdk1.1.7B\bin>

====================XXXXXXXXXXXXXXXXXXXXXXXXXX================================

//*MODEL PROGRAM FOR EMPLOYEE PAY ROLL USING "THIS" KEYWORD.....

2) EMPLOYEE PAY ROLL AND "THIS" KEYWORD

import java.io.*;

class employeepayroll

String emp_name,emp_no;

int basic_salary;

employeepayroll(String emp_name,String emp_no,int basic_salary)

this.emp_name=emp_name;

this.emp_no=emp_no;

this.basic_salary=basic_salary;

void display()

System.out.println("==========================================");

System.out.println("\t Employee PayRoll Details..");

System.out.println("==========================================");

System.out.println("Employee Name="+emp_name);

System.out.println("Employee number="+emp_no);

System.out.println("Employee basic salary="+basic_salary);


}

class employeepayroll1

public static void main(String args[])throws IOException

DataInputStream in=new DataInputStream(System.in);

String emp_na,emp_no;

int basic_sal;

int hra,ta,pf,lic,da,grossprofit,netprofit;

System.out.println("Enter the employee name..");

emp_na=in.readLine();

System.out.println("Enter the employee number..");

emp_no=in.readLine();

System.out.println("Enter the employee salary...");

basic_sal=Integer.parseInt(in.readLine());

if(basic_sal<=5000)

hra=basic_sal*3/100;

ta=basic_sal*2/100;

pf=basic_sal*4/100;
lic=basic_sal*4/100;

da=basic_sal*3/100;

else if(basic_sal>5000&&basic_sal<=10000)

hra=basic_sal*4/100;

ta=basic_sal*3/100;

pf=basic_sal*5/100;

lic=basic_sal*5/100;

da=basic_sal*4/100;

else

hra=basic_sal*5/100;

ta=basic_sal*6/100;

pf=basic_sal*4/100;

lic=basic_sal*5/100;

da=basic_sal*5/100;

grossprofit=basic_sal+hra+ta+da;

netprofit=grossprofit-pf-lic;

employeepayroll e=new employeepayroll(emp_na,emp_no,basic_sal);

e.display();

System.out.println("Hra="+hra);
System.out.println("Ta="+ta);

System.out.println("Pf="+pf);

System.out.println("Lic="+lic);

System.out.println("Da="+da);

System.out.println("Gross profit is="+grossprofit);

System.out.println("Net profit is="+netprofit);

System.out.println("=======================================");

OUTPUT:

Enter the employee name..

SATHISH

Enter the employee number..

1111

Enter the employee salary...

12000

==========================================

Employee PayRoll Details..

==========================================

Employee Name=SATHISH

Employee number=1111

Employee basic salary=12000

Hra=600
Ta=720

Pf=480

Lic=600

Da=600

Gross profit is=13920

Net profit is=12840

=======================================

================================XXXXXXXXXXXXXXX=================================

//*MODEL PROGRAM FOR EB_BILL USING MUTILEVEL INHERITENSE

3) MULTILEVEL INHERITENSE USING THE EB_BILL

import java.io.*;

class ebbill

String cus_name,cus_ebno;

int old_read,new_read,unit,amount;

class ebbill1 extends ebbill

void calculation()

unit=new_read-old_read;

if(unit<=100)

amount=unit*0;

else if(unit>100&&unit<=400)
amount=unit*2;

else if(unit>400&&unit<=950)

amount=unit*4;

else

amount=unit*6;

class ebbill2 extends ebbill1

void display()

System.out.println("=========================================");

System.out.println("\t Electricity Bill ..");

System.out.println("=========================================");

System.out.println("Customer Name="+cus_name);

System.out.println("Customer Eb_Number="+cus_ebno);

System.out.println("New Read is="+new_read);

System.out.println("Old Read is="+old_read);

System.out.println("The Unit is="+unit);

System.out.println("The Amount is="+amount);

System.out.println("=========================================");

class ebbill3

{
public static void main(String args[])throws IOException

DataInputStream in=new DataInputStream(System.in);

ebbill2 e=new ebbill2();

System.out.println("Enter the customer name..");

e.cus_name=in.readLine();

System.out.println("Enter the customer eb_no..");

e.cus_ebno=in.readLine();

System.out.println("Enter the New read...");

e.new_read=Integer.parseInt(in.readLine());

System.out.println("Enter the old read...");

e.old_read=Integer.parseInt(in.readLine());

e.display();

e.calculation();

OUTPUT:

Enter the customer name..

sathish

Enter the customer eb_no..

1111

Enter the New read...


1000

Enter the old read...

300

=========================================

Electricity Bill ..

=========================================

Customer Name=sathish

Customer Eb_Number=1111

New Read is=1000

Old Read is=300

The Unit is=0

The Amount is=0

=========================================

================================XXXXXXXXXXXXXXX=================================

//*MODEL PROGRAM FOR INTERFACE USING THE PRODUCT DETAILS....

4) INTERFACE USING PRODUCT DETAILS...

import java.io.*;

interface product

void calculation();

void display();

class product1 implements product

{
String product_name;

int product_id,quantity,price;

double amount;

public void calculation()

amount=quantity*price;

public void display()

System.out.println("=========================================");

System.out.println("\t Product Details...");

System.out.println("=========================================");

System.out.println("Product name="+product_name);

System.out.println("Product Id="+product_id);

System.out.println("Quantiy="+quantity);

System.out.println("Price="+price);

System.out.println("Amount="+amount);

System.out.println("=========================================");

class products1

public static void main(String args[])throws IOException

DataInputStream in=new DataInputStream(System.in);


{

product1 p=new product1();

System.out.println("Enter the product name..");

p.product_name=in.readLine();

System.out.println("Enter the product id..");

p.product_id=Integer.parseInt(in.readLine());

System.out.println("Enter the Quantity..");

p.quantity=Integer.parseInt(in.readLine());

System.out.println("Enter the Price..");

p.price=Integer.parseInt(in.readLine());

p.calculation();

p.display();

OUTPUT:

Enter the product name..

sathish

Enter the product id..

1111

Enter the Quantity..

10

Enter the Price..

1000
=========================================

Product Details...

=========================================

Product name=sathish

Product Id=1111

Quantiy=10

Price=1000

Amount=10000.0

=========================================

========================XXXXXXXXX======================

THE END

You might also like