0% found this document useful (0 votes)
33 views158 pages

Oop Record 22-23

This document provides the details of a lab experiment conducted by a student to generate electricity bills. It includes the student's registration number, date on which the university examination was held, internal and external examiners' signatures against each experiment conducted, along with the aim, procedure, program and output of the electricity bill generation experiment. The document is issued by the Pet Engineering College, Tirunelveli certifying the bonafide work done by the student in partial fulfillment of the B.E. degree requirements of Anna University, Chennai.

Uploaded by

padma sree
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)
33 views158 pages

Oop Record 22-23

This document provides the details of a lab experiment conducted by a student to generate electricity bills. It includes the student's registration number, date on which the university examination was held, internal and external examiners' signatures against each experiment conducted, along with the aim, procedure, program and output of the electricity bill generation experiment. The document is issued by the Pet Engineering College, Tirunelveli certifying the bonafide work done by the student in partial fulfillment of the B.E. degree requirements of Anna University, Chennai.

Uploaded by

padma sree
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/ 158

PET ENGINEERING COLLEGE

TIRUCHENDUR ROAD, VALLIOOR-627 117,

TIRUNELVELI DISTRICT.

Certified that this is the bonafide record of the work done by


Mr./Ms………………………………………………………………. of the Fifth Semester in
The department of ELECTRICAL&ELECTRONICS ENGINEERING of this college
in the CS8383 OBJECT ORIENTED PROGRAMMING LABORATORY during 2022-
2023 in the partial fulfillment of the requirements of B.E degree course of the ANNA
UNIVESITY, CHENNAI.

Staff In-Charge Head of the Department

University Reg.no : ……………………………………..

University Examination held on. . . . . . . . . . . . . . . . . . . . . . .

Internal Examiner External Examiner


S.NO. DATE TITLE PAGE NO. SIGNATURE

1 Generation of Electricity Bill

Implementation Of Currency,
2 Distance And Time Converter
Using Packages

Generation Of Payslip Using


3
Inheritance

Implementation Of Stack ADT


4
Using Interface

5 String Operations Using Arraylist

Calculation Of Area Using Abstract


6
Class

Implementation Of User Defined


7
Exception Handling

8 Displaying File Information

Implementation Of Multithreaded
9
Application

Finding the maximum value using


10
Generics

Calculator Using Event Driven


11
Programming

12 Mini Project – Fee Management


EX NO : 1 ELECTRICITY BILL GENERATION

AIM

PROCEDURE

1. Create a class with the following members

Consumer no., consumer name, previous month reading, current month reading, type of EB
connection (i.e domestic or commercial)

2. Compute the bill amount using the following tariff.

If the type of the EB connection is domestic, calculate the amount to be paid as follows:

 First 100 units - Rs. 1 per unit

 101-200 units - Rs. 2.50 per unit

 201 -500 units - Rs. 4 per unit

 > 501 units - Rs. 6 per unit

If the type of the EB connection is commercial, calculate the amount to be paid as follows:

 First 100 units - Rs. 2 per unit

 101-200 units - Rs. 4.50 per unit

 201 -500 units - Rs. 6 per unit

 > 501 units - Rs. 7 per unit

3. Create the object for the created class .Invoke the methods to get the input from the consumer

and display the consumer information with the generated electricity bill.
PROGRAM
import java.util.*;
class ebill
{
public static void main (String args[])
{
customerdata ob = new customerdata();
ob.getdata();
ob.calc();
ob.display();
}

}
class customerdata
{
Scanner in = new Scanner(System.in);
Scanner ins = new Scanner(System.in);

String cname,type;

int bn;
double current,previous,tbill,units;

void getdata()
{
System.out.print ("\n\t Enter consumer number ");
bn = in.nextInt();

System.out.print ("\n\t Enter Type of connection (D for Domestic or C for Commercial) ");
type = ins.nextLine();
System.out.print ("\n\t Enter consumer name ");
cname = ins.nextLine();

System.out.print ("\n\t Enter previous month reading ");


previous= in.nextDouble();

System.out.print ("\n\t Enter current month reading ");


current= in.nextDouble();
}
void calc()
{

units=current-previous;
if(type.equals("D"))
{
if (units<=100)

tbill=1 * units;
else if (units>100 && units<=200)
tbill=2.50*units;
else if(units>200 && units<=500)
tbill= 4*units;
else
tbill= 6*units;
}
else

if (units<=100)
tbill= 2 * units;

else if(units>100 && units<=200)


tbill=4.50*units;
else if(units>200 && units<=500)
tbill= 6*units;
else
tbill= 7*units;
}
}

void display()
{
System.out.println("\n\t Consumer number = "+bn);
System.out.println ("\n\t Consumer name = "+cname);
if(type.equals("D"))
System.out.println ("\n\t type of connection = DOMESTIC ");
else
System.out.println ("\n\t type of connection = COMMERCIAL ");
System.out.println ("\n\t Current Month Reading = "+current);
System.out.println ("\n\t Previous Month Reading = "+previous);

System.out.println ("\n\t Total units = "+units);

System.out.println ("\n\t Total bill = RS "+tbill);


}

}
OUTPUT

RESULT
EX NO: 2 IMPLEMENTATION OF CURRENCY, DISTANCE AND TIME
CONVERTER USING PACKAGES

AIM

PROCEDURE

1. Create a Package currencyconversion and place the class currency under the package
2. Create the methods to perform currency conversion from dollar to rupee ,rupee to
dollar,euro to rupee , rupee to euro , yen to rupee and rupee to yen.
3. Create the package distanceconverion and create the class distance within the package
4. Create the methods to convert from meter to km, km to meter, miles to km,km to miles
5. Create the package timeconversion and create the class timer .Create the methods to
convert from hours to minutes ,hours to seconds , minutes to hours and seconds to hours
6. Create a class and import the packages currencyconversion,distanceconversion and time
conversion.Create the objects for the class currency,distance and timer.
7. Get the choice from the user and invoke the methods to perform the corresponding
conversion and display the value.

PROGRAM
currencyconversion.java
package currencyconversion;
import java.util.*;
public class currency
{
double inr,usd;
double euro,yen;

Scanner in=new Scanner(System.in);


public void dollartorupee()
{
System.out.println("Enter dollars to convert into Rupees:");
usd=in.nextInt();
inr=usd*67;
System.out.println("Dollar ="+usd+"equal to INR="+inr);
}
public void rupeetodollar()

{
System.out.println("Enter Rupee to convert into Dollars:");
inr=in.nextInt();
usd=inr/67;
System.out.println("Rupee ="+inr+"equal to Dollars="+usd);
}
public void eurotorupee()

{
System.out.println("Enter euro to convert into Rupees:");

euro=in.nextInt();
inr=euro*79.50;
System.out.println("Euro ="+euro +"equal to INR="+inr);

}
public void rupeetoeuro()
{
System.out.println("Enter Rupees to convert into Euro:");
inr=in.nextInt();

euro=(inr/79.50);
System.out.println("Rupee ="+inr +"equal to Euro="+euro);

}
public void yentorupee()
{
System.out.println("Enter yen to convert into Rupees:");
yen=in.nextInt();
inr=yen*0.61;
System.out.println("YEN="+yen +"equal to INR="+inr);
}

public void rupeetoyen()


{
System.out.println("Enter Rupees to convert into Yen:");
inr=in.nextInt();
yen=(inr/0.61);
System.out.println("INR="+inr +"equal to YEN"+yen);
}

distance.java
package distanceconversion;

import java.util.*;
public class distance
{
double km,m,miles;
Scanner sc = new Scanner(System.in);

public void kmtom()


{
System.out.print("Enter in km ");
km=sc.nextDouble();
m=(km*1000);
System.out.println(km+"km" +"equal to"+m+"metres");
}

public void mtokm()


{

System.out.print("Enter in meter ");


m=sc.nextDouble();
km=(m/1000);
System.out.println(m+"m" +"equal to"+km+"kilometres");
}

public void milestokm()


{
System.out.print("Enter in miles");
miles=sc.nextDouble();
km=(miles*1.60934);
System.out.println(miles+"miles" +"equal to"+km+"kilometres");
}
public void kmtomiles()
{

System.out.print("Enter in km");
km=sc.nextDouble();
miles=(km*0.621371);

System.out.println(km+"km" +"equal to"+miles+"miles");


}
}

timer.java
package timeconversion;

import java.util.*;
public class timer
{

int hours,seconds,minutes;
int input;

Scanner sc = new Scanner(System.in);


public void secondstohours()
{
System.out.print("Enter the number of seconds: ");
input = sc.nextInt();
hours = input / 3600;
minutes = (input % 3600) / 60;
seconds = (input % 3600) % 60;

System.out.println("Hours: " + hours);

System.out.println("Minutes: " + minutes);


System.out.println("Seconds: " + seconds);
}
public void minutestohours()
{

System.out.print("Enter the number of minutes: ");


minutes=sc.nextInt();
hours=minutes/60;
minutes=minutes%60;
System.out.println("Hours: " + hours);

System.out.println("Minutes: " + minutes);


}

public void hourstominutes()


{
System.out.println("enter the no of hours");
hours=sc.nextInt();
minutes=(hours*60);
System.out.println("Minutes: " + minutes);
}
public void hourstoseconds()

{
System.out.println("enter the no of hours");
hours=sc.nextInt();
seconds=(hours*3600);
System.out.println("Minutes: " + seconds);
}
}

converter.java
import java.util.*;
import java.io.*;

import currencyconversion.*;
import distanceconversion.*;
import timeconversion.*;
class converter
{
public static void main(String args[])

Scanner s=new Scanner(System.in);


int choice,ch;
currency c=new currency();
distance d=new distance();
timer t=new timer();
do

{
System.out.println("1.dollar to rupee ");
System.out.println("2.rupee to dollar ");
System.out.println("3.Euro to rupee ");

System.out.println("4..rupee to Euro ");


System.out.println("5.Yen to rupee ");

System.out.println("6.Rupee to Yen ");


System.out.println("7.Meter to kilometer ");
System.out.println("8.kilometer to meter ");

System.out.println("9.Miles to kilometer ");


System.out.println("10.kilometer to miles");

System.out.println("11.Hours to Minutes");
System.out.println("12.Hours to Seconds");
System.out.println("13.Seconds to Hours");

System.out.println("14.Minutes to Hours");
System.out.println("Enter ur choice");

choice=s.nextInt();
switch(choice)
{
case 1:
{
c.dollartorupee();

break;
}
case 2:
{
c.rupeetodollar();
break;
}
case 3:
{

c.eurotorupee();
break;
}
case 4:
{
c.rupeetoeuro();

break;

}
case 5:

{c.yentorupee();
break;}
case 6 :
{

c.rupeetoyen();

break;
}
case 7 :
{

d.mtokm();
break;

}
case 8 :
{

d.kmtom();
break;

}
case 9 :
{

d.milestokm();
break;
}
case 10 :
{

d.kmtomiles();
break;
}
case 11 :
{
t.hourstominutes();

break;
}
case 12 :
{

t.hourstoseconds();
break;
}
case 13 :
{
t.secondstohours();
break;

}
case 14 :

{
t.minutestohours();
break;

}}
System.out.println("Enter 0 to quit and 1 to continue ");
ch=s.nextInt();

}while(ch==1);
}
}

OUTPUT
RESULT
EX NO: 3 GENERATION OF PAYSLIP USING INHERITANCE

AIM

PROCEDURE

1. Create the class employee with name, Empid, address, mailid, mobileno as members.
2. Inherit the classes programmer, asstprofessor,associateprofessor and professor from
employee class.
3. Add Basic Pay (BP) as the member of all the inherited classes.
4. Calculate DA as 97% of BP, HRA as 10% of BP, PF as 12% of BP, Staff club fund as 0.1% of
BP.
5. Calculate gross salary and net salary.
6. Generate payslip for all categories of employees.
7.Create the objects for the inherited classes and invoke the necessary methods to display the
Payslip.

PROGRAM
import java.util.*;
class employee

{
int empid;
long mobile;

String name, address, mailid;


Scanner get = new Scanner(System.in);

void getdata()
{
System.out.println("Enter Name of the Employee");
name = get.nextLine();

System.out.println("Enter Mail id");


mailid = get.nextLine();

System.out.println("Enter Address of the Employee:");


address = get.nextLine();

System.out.println("Enter employee id ");


empid = get.nextInt();
System.out.println("Enter Mobile Number");
mobile = get.nextLong();
}
void display()
{
System.out.println("Employee Name: "+name);
System.out.println("Employee id : "+empid);
System.out.println("Mail id : "+mailid);

System.out.println("Address: "+address);
System.out.println("Mobile Number: "+mobile);

}
}

class programmer extends employee


{
double salary,bp,da,hra,pf,club,net,gross;

void getprogrammer()
{
System.out.println("Enter basic pay");

bp = get.nextDouble();
}
void calculateprog()
{
da=(0.97*bp);

hra=(0.10*bp);
pf=(0.12*bp);

club=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-club);

System.out.println("************************************************");
System.out.println("PAY SLIP FOR PROGRAMMER");

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("CLUB:Rs"+club);
System.out.println("GROSS PAY:Rs"+gross);

System.out.println("NET PAY:Rs"+net);

}
}

class asstprofessor extends employee


{
double salary,bp,da,hra,pf,club,net,gross;
void getasst()
{
System.out.println("Enter basic pay");

bp = get.nextDouble();

}
void calculateasst()
{

da=(0.97*bp);
hra=(0.10*bp);
pf=(0.12*bp);

club=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-club);

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

System.out.println("PAY SLIP FOR ASSISTANT PROFESSOR");

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("CLUB:Rs"+club);
System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);
}
}
class associateprofessor extends employee
{

double salary,bp,da,hra,pf,club,net,gross;
void getassociate()
{

System.out.println("Enter basic pay");

bp = get.nextDouble();
}
void calculateassociate()

da=(0.97*bp);
hra=(0.10*bp);
pf=(0.12*bp);
club=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-club);

System.out.println("************************************************");
System.out.println("PAY SLIP FOR ASSOCIATE PROFESSOR");
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("CLUB:Rs"+club);

System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);

}
}

class professor extends employee


{
double salary,bp,da,hra,pf,club,net,gross;

void getprofessor()
{
System.out.println("Enter basic pay");

bp = get.nextDouble();
}

void calculateprofessor()
{

da=(0.97*bp);
hra=(0.10*bp);
pf=(0.12*bp);

club=(0.1*bp);
gross=(bp+da+hra);
net=(gross-pf-club);

System.out.println("************************************************");
System.out.println("PAY SLIP FOR PROFESSOR");
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("CLUB:Rs"+club);

System.out.println("GROSS PAY:Rs"+gross);
System.out.println("NET PAY:Rs"+net);

}
}

class salary
{
public static void main(String args[])
{

int choice,cont;

do
{

System.out.println("PAYROLL");

System.out.println(" 1.PROGRAMMER \t 2.ASSISTANT PROFESSOR \t 3.ASSOCIATE


PROFESSOR \t 4.PROFESSOR ");
Scanner c = new Scanner(System.in);
choice=c.nextInt();

switch(choice)
{

case 1:
{
programmer p=new programmer();
p.getdata();

p.getprogrammer();
p.display();
p.calculateprog();

break;

}
case 2:
{
asstprofessor asst=new asstprofessor();
asst.getdata();
asst.getasst();
asst.display();

asst.calculateasst();
break;

}
case 3:
{

associateprofessor asso=new associateprofessor();


asso.getdata();

asso.getassociate();
asso.display();
asso.calculateassociate();
break;
}
case 4:
{
professor prof=new professor();
prof.getdata();
prof.getprofessor();

prof.display();
prof.calculateprofessor();

break;

}
}
System.out.println("Do u want to continue 0 to quit and 1 to continue ");

cont=c.nextInt();
}while(cont==1);
}

}
OUTPUT

RESULT
EX NO: 4 IMPLEMENTATION OF STACK ADT USING INTERFACE

AIM

PROCEDURE

1. Create the interface stackoperation with method declarations for push and pop.
2. Create the class astack which implements the interface and provides implementation for
the methods push and pop.Also define the method for displaying the values stored in the
stack.Handle the stack overflow and stack underflow condition .
3. Create the class teststack .Get the choice from the user for the operation to be performed .
and also handle the exception that occur while performing the stack operation.
4. Create the object and invoke the method for push,pop,display based on the input from the
user.

PROGRAM
import java.io.*;
interface stackoperation
{
public void push(int i);

public void pop();


}
class Astack implements stackoperation
{
int stack[]=new int[5];
int top=-1;

int i;
public void push(int item)

{
if(top>=4)
{

System.out.println("overflow");
}

else
{

top=top+1;
stack[top]=item;
System.out.println("item pushed"+stack[top]);

}
}
public void pop()
{
if(top<0)
System.out.println("underflow");
else

{
System.out.println("item popped"+stack[top]);
top=top-1;

}
}

public void display()


{
if(top<0)

System.out.println("No Element in stack");


else

{
for(i=0;i<=top;i++)
System.out.println("element:"+stack[i]);

}
}

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

int ch,c;
int i;
Astack s=new Astack();

DataInputStream in=new DataInputStream(System.in);


do
{
try
{
System.out.println("ARRAY STACK");
System.out.println("1.push 2.pop 3.display 4.exit");
System.out.println("enter ur choice:");
ch=Integer.parseInt(in.readLine());
switch(ch)
{
case 1:

System.out.println("enter the value to push:");


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

s.push(i);
break;
case 2:

s.pop();
break;
case 3:

System.out.println("the elements are:");


s.display();

break;
case 4:
break;
}
}
catch(IOException e)

{
System.out.println("io error");
}

System.out.println("Do u want to continue 0 to quit and 1 to continue ");

c=Integer.parseInt(in.readLine());
}while(c==1);
}
}

OUTPUT
RESULT
EX NO: 5 STRING OPERATIONS USING ARRAYLIST

AIM

PROCEDURE

1.Create the class arraylistexample. Create the object for the arraylist class.

2.Display the options to the user for performing string handling .

3. Use the function add() to append the string at the end and to insert the string at the
particular index.

4. The function sort () is used to sort the elements in the array list.

5. The function indexof() is used to search whether the element is in the array list or not.

6. The function startsWith () is used to find whether the element starts with the specified
character.

7. The function remove() is used to remove the element from the arraylist.

8. The function size() is used to determine the number of elements in the array list.
PROGRAM
import java.util.*;
import java.io.*;
public class arraylistexample
{
public static void main(String args[])throws IOException
{

ArrayList<String> obj = new ArrayList<String>();


DataInputStream in=new DataInputStream(System.in);
int c,ch;

int i,j;
String str,str1;
do
{
System.out.println("STRING MANIPULATION");
System.out.println("******************************");
System.out.println(" 1. Append at end \t 2.Insert at particular index \t 3.Search \t");
System.out.println( "4.List string that starting with letter \t");
System.out.println("5.Size \t 6.Remove \t 7.Sort\t 8.Display\t" );
System.out.println("Enter the choice ");
c=Integer.parseInt(in.readLine());
switch(c)
{
case 1:
{
System.out.println("Enter the string ");
str=in.readLine();

obj.add(str);
break;

}
case 2:
{
System.out.println("Enter the string ");
str=in.readLine();

System.out.println("Specify the index/position to insert");


i=Integer.parseInt(in.readLine());
obj.add(i-1,str);
System.out.println("The array list has following elements:"+obj);

break;
}
case 3:

{
System.out.println("Enter the string to search ");
str=in.readLine();

j=obj.indexOf(str);
if(j==-1)
System.out.println("Element not found");

else

System.out.println("Index of:"+str+"is"+j);
break;
}
case 4:
{
System.out.println("Enter the character to List string that starts with specified character");
str=in.readLine();
for(i=0;i<(obj.size()-1);i++)
{
str1=obj.get(i);
if(str1.startsWith(str))

{
System.out.println(str1);

}
}
break;

}
case 5:
{

System.out.println("Size of the list "+obj.size());


break;
}
case 6:
{
System.out.println("Enter the element to remove");
str=in.readLine();
if(obj.remove(str))
{
System.out.println("Element Removed"+str);

}
else
{
System.out.println("Element not present");

}
break;

}
case 7:
{
Collections.sort(obj);
System.out.println("The array list has following elements:"+obj);
break;

}
case 8:
{
System.out.println("The array list has following elements:"+obj);
break;
}
}
System.out.println("enter 0 to break and 1 to continue");

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

}while(ch==1);
}
}
OUTPUT

RESULT

.
EX NO : 6 PROGRAM TO CALCULATE AREA USING ABSTRACT CLASS

AIM

PROCEDURE

1. Create an abstract class named shape that contains two integers and an empty method named
printarea().

2. Provide three classes named rectangle, triangle and circle such that each one of the classes
extends the class Shape.

3.Each of the inherited class from shape class should provide the implementation for the method
printarea().

4.Get the input and calculate the area of rectangle,circle and triangle .

5. In the shapeclass , create the objects for the three inherited classes and invoke the methods and
display the area values of the different shapes.

PROGRAM
import java.util.*;
abstract class shape
{
int a,b;
abstract public void printarea();
}

class rectangle extends shape


{
public int area_rect;
public void printarea()

{
Scanner s=new Scanner(System.in);

System.out.println("enter the length and breadth of rectangle");


a=s.nextInt();

b=s.nextInt();
area_rect=a*b;
System.out.println("Length of rectangle "+a +"breadth of rectangle "+b);
System.out.println("The area ofrectangle is:"+area_rect);
}
}
class triangle extends shape
{

double area_tri;

public void printarea()


{
Scanner s=new Scanner(System.in);
System.out.println("enter the base and height of triangle");
a=s.nextInt();
b=s.nextInt();
System.out.println("Base of triangle "+a +"height of triangle "+b);
area_tri=(0.5*a*b);
System.out.println("The area of triangle is:"+area_tri);
}

}
class circle extends shape

{
double area_circle;

public void printarea()


{

Scanner s=new Scanner(System.in);


System.out.println("enter the radius of circle");
a=s.nextInt();

area_circle=(3.14*a*a);
System.out.println("Radius of circle"+a);
System.out.println("The area of circle is:"+area_circle);
}

}
public class shapeclass
{
public static void main(String[] args)
{
rectangle r=new rectangle();
r.printarea();

triangle t=new triangle();


t.printarea();
circle r1=new circle();

r1.printarea();
}
}

OUTPUT
RESULT
EX NO : 7 IMPLEMENTATION OF USER DEFINED EXCEPTION HANDLING

AIM

PROCEDURE

1. Create a class which extends Exception class.

2. Create a constructor which receives the string as argument.

3.Get the Amount as input from the user.


4. If the amount is negative , the exception will be generated.

5. Using the exception handling mechanism , the thrown exception is handled by the catch

construct.
6. After the exception is handled , the string “invalid amount “ will be displayed.

7. If the amount is greater than 0 , the message “Amount Deposited “ will be displayed

(a) PROGRAM

import java.util.Scanner;
class NegativeAmtException extends Exception
{
String msg;
NegativeAmtException(String msg)
{
this.msg=msg;
}

public String toString()


{
return msg;
}

}
public class userdefined

{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.print("Enter Amount:");
int a=s.nextInt();

try
{
if(a<0)
{
throw new NegativeAmtException("Invalid Amount");
}

System.out.println("Amount Deposited");
}
catch(NegativeAmtException e)
{
System.out.println(e);
}
}

}
OUTPUT

(b) PROGRAM

class MyException extends Exception{


String str1;
MyException(String str2)
{
str1=str2;
}

public String toString()


{
return ("MyException Occurred: "+str1) ;
}
}
class example

{
public static void main(String args[])
{
try

{
System.out.println("Starting of try block");

throw new MyException("This is My error Message");


}
catch(MyException exp)
{
System.out.println("Catch Block") ;
System.out.println(exp) ;

}
}}

OUTPUT

RESULT
EX NO :8 DISPLAYING FILE INFORMATION

AIM

PROCEDURE

1. Create a class filedemo. Get the file name from the user .
2. Use the file functions and display the information about the file.
3.getName() displays the name of the file.
4. getPath() diplays the path name of the file.
5. getParent () -This method returns the pathname string of this abstract pathname’s parent, or
null if this pathname does not name a parent directory.
6. exists() – Checks whether the file exists or not.
7. canRead()-This method is basically a check if the file can be read.
8. canWrite()-verifies whether the application can write to the file.
9. isDirectory() – displays whether it is a directory or not.
10. isFile() – displays whether it is a file or not.
11. lastmodified() – displays the last modified information.
12.length()- displays the size of the file.
13. delete() – deletes the file
14.Invoke the predefined functions abd display the iformation about the file.
PROGRAM
import java.io.*;
import java.util.*;
class filedemo

{
public static void main(String args[])
{
String filename;

Scanner s=new Scanner(System.in);


System.out.println("Enter the file name ");
filename=s.nextLine();
File f1=new File(filename);
System.out.println("*****************");
System.out.println("FILE INFORMATION");
System.out.println("*****************");
System.out.println("NAME OF THE FILE "+f1.getName());
System.out.println("PATH OF THE FILE "+f1.getPath());
System.out.println("PARENT"+f1.getParent());
if(f1.exists())

System.out.println("THE FILE EXISTS ");


else
System.out.println("THE FILE DOES NOT ExISTS ");
if(f1.canRead())
System.out.println("THE FILE CAN BE READ ");
else
System.out.println("THE FILE CANNOT BE READ ");
if(f1.canWrite())
System.out.println("WRITE OPERATION IS PERMITTED");
else
System.out.println("WRITE OPERATION IS NOT PERMITTED");
if(f1.isDirectory())
System.out.println("IT IS A DIRECTORY ");
else

System.out.println("NOT A DIRECTORY");
if(f1.isFile())
System.out.println("IT IS A FILE ");

else
System.out.println("NOT A FILE");
System.out.println("File last modified "+ f1.lastModified());

System.out.println("LENGTH OF THE FILE "+f1.length());


System.out.println("FILE DELETED "+f1.delete());
}
}

OUTPUT
RESULT
EX NO :9 IMPLEMENT AN MULTITHREADED APPLICATION

AIM

PROCEDURE

1. Create a class even which implements first thread that computes .the square of the number .

2. run() method implements the code to be executed when thread gets executed.

3. Create a class odd which implements second thread that computes the cube of the number.

4. Create a third thread that generates random number.If the random number is even , it displays
the square of the number.If the random number generated is odd , it displays the cube of the
given number .

5. The Multithreading is performed and the task switched between multiple threads.

6.The sleep () method makes the thread to suspend for the specified time.
PROGRAM
import java.util.*;
class even implements Runnable
{
public int x;
public even(int x)

{
this.x = x;
}
public void run()
{
System.out.println("New Thread "+ x +" is EVEN and Square of " + x + " is: " + x * x);

}
}

class odd implements Runnable


{

public int x;
public odd(int x)
{

this.x = x;
}
public void run()
{
System.out.println("New Thread "+ x +" is ODD and Cube of " + x + " is: " + x * x * x);
}

}
class A extends Thread
{

public void run()


{

int num = 0;
Random r = new Random();
try

{
for (int i = 0; i < 5; i++)

{
num = r.nextInt(100);
System.out.println("Main Thread and Generated Number is " + num);
if (num % 2 == 0)
{
Thread t1 = new Thread(new even(num));

t1.start();

}
else
{
Thread t2 = new Thread(new odd(num));
t2.start();
}
Thread.sleep(1000);
System.out.println(" ");
}

}
catch (Exception ex)
{
System.out.println(ex.getMessage());

}
}

}
public class multithreadprog
{
public static void main(String[] args)
{

A a = new A();
a.start();
}
}

OUTPUT

RESULT
EX NO: 10 FINDING THE MAXIMUM VALUE USING GENERICS

AIM

PROCEDURE

1.Create a class Myclass to implement generic class and generic methods.


2.Get the set of the values belonging to specific data type.
3. Create the objects of the class to hold integer,character and double values.

4. Create the method to compare the values and find the maximum value stored in the array.

5.Invoke the method with integer, character or double values . The output will be displayed
based on the data type passed to the method.

PROGRAM
class MyClass<T extends Comparable<T>>

T[] vals;
MyClass(T[] o)
{
vals = o;
}
public T min()

{
T v = vals[0];

for(int i=1; i < vals.length; i++)


if(vals[i].compareTo(v) < 0)
v = vals[i];
return v;
}
public T max()
{

T v = vals[0];
for(int i=1; i < vals.length;i++)
if(vals[i].compareTo(v) > 0)
v = vals[i];
return v;
}
}
class gendemo
{

public static void main(String args[])


{
int i;

Integer inums[]={10,2,5,4,6,1};

Character chs[]={'v','p','s','a','n','h'};
Double d[]={20.2,45.4,71.6,88.3,54.6,10.4};
MyClass<Integer> iob = new MyClass<Integer>(inums);
MyClass<Character> cob = new MyClass<Character>(chs);
MyClass<Double>dob = new MyClass<Double>(d);

System.out.println("Max value in inums: " + iob.max());


System.out.println("Min value in inums: " + iob.min());

System.out.println("Max value in chs: " + cob.max());


System.out.println("Min value in chs: " + cob.min());
System.out.println("Max value in chs: " + dob.max());
System.out.println("Min value in chs: " + dob.min());
}
}

OUTPUT

RESULT
EX NO: 11 CALCULATOR USING EVENT DRIVEN PROGRAMMING

AIM

PROCEDURE

1. import the swing packages and awt packages.


2. Create the class scientificcalculator that implements action listener.
3. Create the container and add controls for digits , scientific calculations and decimal
Manipulations.
4. The different layouts can be used to lay the controls.
5.When the user presses the control , the event is generated and handled .
6. The corresponding decimal , numeric and scientific calculations are performed.
A)Scientific Calculator

PROGRAM
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

import javax.swing.event.*;
public class ScientificCalculator extends JFrame implements ActionListener
{
JTextField tfield;

double temp, temp1, result, a;


static double m1, m2;
int k = 1, x = 0, y = 0, z = 0;
char ch;

JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, zero, clr, pow2, pow3, exp,
fac, plus, min, div, log, rec, mul, eq, addSub, dot, mr, mc, mp,
mm, sqrt, sin, cos, tan;
Container cont;
JPanel textPanel, buttonpanel;
ScientificCalculator()
{

cont = getContentPane();
cont.setLayout(new BorderLayout());
JPanel textpanel = new JPanel();

tfield = new JTextField(25);

tfield.setHorizontalAlignment(SwingConstants.RIGHT);

tfield.addKeyListener(new KeyAdapter() {

public void keyTyped(KeyEvent keyevent) {


char c = keyevent.getKeyChar();
if (c >= '0' && c <= '9') {
}
else
{

keyevent.consume();
}
}

});
textpanel.add(tfield);
buttonpanel = new JPanel();
buttonpanel.setLayout(new GridLayout(8, 4, 2, 2));
boolean t = true;
mr = new JButton("MR");
buttonpanel.add(mr);
mr.addActionListener(this);
mc = new JButton("MC");
buttonpanel.add(mc);
mc.addActionListener(this);
mp = new JButton("M+");
buttonpanel.add(mp);
mp.addActionListener(this);
mm = new JButton("M-");
buttonpanel.add(mm);
mm.addActionListener(this);
b1 = new JButton("1");
buttonpanel.add(b1);
b1.addActionListener(this);
b2 = new JButton("2");
buttonpanel.add(b2);
b2.addActionListener(this);
b3 = new JButton("3");
buttonpanel.add(b3);
b3.addActionListener(this);
b4 = new JButton("4");
buttonpanel.add(b4);
b4.addActionListener(this);
b5 = new JButton("5");
buttonpanel.add(b5);
b5.addActionListener(this);
b6 = new JButton("6");
buttonpanel.add(b6);
b6.addActionListener(this);
b7 = new JButton("7");
buttonpanel.add(b7);
b7.addActionListener(this);
b8 = new JButton("8");
buttonpanel.add(b8);
b8.addActionListener(this);
b9 = new JButton("9");
buttonpanel.add(b9);
b9.addActionListener(this);
zero = new JButton("0");
buttonpanel.add(zero);
zero.addActionListener(this);

plus = new JButton("+");


buttonpanel.add(plus);

plus.addActionListener(this);
min = new JButton("-");
buttonpanel.add(min);

min.addActionListener(this);
mul = new JButton("*");

buttonpanel.add(mul);
mul.addActionListener(this);
div = new JButton("/");

div.addActionListener(this);
buttonpanel.add(div);

addSub = new JButton("+/-");


buttonpanel.add(addSub);
addSub.addActionListener(this);
dot = new JButton(".");
buttonpanel.add(dot);
dot.addActionListener(this);
eq = new JButton("=");
buttonpanel.add(eq);
eq.addActionListener(this);
rec = new JButton("1/x");
buttonpanel.add(rec);
rec.addActionListener(this);
sqrt = new JButton("Sqrt");
buttonpanel.add(sqrt);
sqrt.addActionListener(this);

log = new JButton("log");


buttonpanel.add(log);

log.addActionListener(this);
sin = new JButton("SIN");
buttonpanel.add(sin);

sin.addActionListener(this);
cos = new JButton("COS");

buttonpanel.add(cos);
cos.addActionListener(this);
tan = new JButton("TAN");

buttonpanel.add(tan);
tan.addActionListener(this);

pow2 = new JButton("x^2");


buttonpanel.add(pow2);

pow2.addActionListener(this);
pow3 = new JButton("x^3");
buttonpanel.add(pow3);

pow3.addActionListener(this);
exp = new JButton("Exp");

exp.addActionListener(this);
buttonpanel.add(exp);
fac = new JButton("n!");
fac.addActionListener(this);

buttonpanel.add(fac);

clr = new JButton("AC");


buttonpanel.add(clr);
clr.addActionListener(this);

cont.add("Center", buttonpanel);
cont.add("North", textpanel);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
String s = e.getActionCommand();
if (s.equals("1"))

{
if (z == 0)
{
tfield.setText(tfield.getText() + "1");
}
else

{
tfield.setText("");
tfield.setText(tfield.getText() + "1");
z = 0;
}
}

if (s.equals("2")) {
if (z == 0) {
tfield.setText(tfield.getText() + "2");
}

else
{
tfield.setText("");
tfield.setText(tfield.getText() + "2");
z = 0;
}
}

if (s.equals("3")) {
if (z == 0) {
tfield.setText(tfield.getText() + "3");
}
else
{

tfield.setText("");

tfield.setText(tfield.getText() + "3");
z = 0;
}
}
if (s.equals("4")) {
if (z == 0) {

tfield.setText(tfield.getText() + "4");
}
else

{
tfield.setText("");
tfield.setText(tfield.getText() + "4");
z = 0;
}
}
if (s.equals("5")) {
if (z == 0) {
tfield.setText(tfield.getText() + "5");
}
else

{
tfield.setText("");
tfield.setText(tfield.getText() + "5");
z = 0;
}
}

if (s.equals("6")) {

if (z == 0) {
tfield.setText(tfield.getText() + "6");
}
else
{

tfield.setText("");
tfield.setText(tfield.getText() + "6");
z = 0;
}
}
if (s.equals("7")) {

if (z == 0) {
tfield.setText(tfield.getText() + "7");
}
else
{

tfield.setText("");
tfield.setText(tfield.getText() + "7");

z = 0;
}
}

if (s.equals("8")) {
if (z == 0) {
tfield.setText(tfield.getText() + "8");
}
else
{
tfield.setText("");

tfield.setText(tfield.getText() + "8");
z = 0;
}
}

if (s.equals("9")) {

if (z == 0) {
tfield.setText(tfield.getText() + "9");
}

else
{
tfield.setText("");
tfield.setText(tfield.getText() + "9");

z = 0;
}
}

if (s.equals("0"))
{

if (z == 0) {
tfield.setText(tfield.getText() + "0");
}
else
{

tfield.setText("");
tfield.setText(tfield.getText() + "0");
z = 0;
}

}
if (s.equals("AC")) {

tfield.setText("");
x = 0;
y = 0;

z = 0;
}
if (s.equals("log"))
{

if (tfield.getText().equals("")) {
tfield.setText("");
}
else
{
a = Math.log(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText() + a);
}
}
if (s.equals("1/x")) {

if (tfield.getText().equals("")) {
tfield.setText("");
}
else
{
a = 1 / Double.parseDouble(tfield.getText());
tfield.setText("");

tfield.setText(tfield.getText() + a);

}
}
if (s.equals("Exp")) {
if (tfield.getText().equals("")) {

tfield.setText("");

}
else
{

a = Math.exp(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText() + a);
}
}
if (s.equals("x^2")) {
if (tfield.getText().equals("")) {
tfield.setText("");
}
else
{

a = Math.pow(Double.parseDouble(tfield.getText()), 2);
tfield.setText("");
tfield.setText(tfield.getText() + a);
}
}
if (s.equals("x^3")) {

if (tfield.getText().equals("")) {

tfield.setText("");
}
else
{
a = Math.pow(Double.parseDouble(tfield.getText()), 3);
tfield.setText("");

tfield.setText(tfield.getText() + a);
}
}

if (s.equals("+/-")) {
if (x == 0) {
tfield.setText("-" + tfield.getText());
x = 1;
}
else
{

tfield.setText(tfield.getText());
}

}
if (s.equals(".")) {
if (y == 0) {

tfield.setText(tfield.getText() + ".");
y = 1;
}
else
{

tfield.setText(tfield.getText());
}
}

if (s.equals("+"))
{
if (tfield.getText().equals(""))

{
tfield.setText("");
temp = 0;
ch = '+';
}
else
{

temp = Double.parseDouble(tfield.getText());

tfield.setText("");
ch = '+';
y = 0;

x = 0;
}

tfield.requestFocus();
}
if (s.equals("-"))
{
if (tfield.getText().equals(""))

{
tfield.setText("");
temp = 0;
ch = '-';
}
else

{
x = 0;
y = 0;

temp = Double.parseDouble(tfield.getText());
tfield.setText("");
ch = '-';
}
tfield.requestFocus();
}
if (s.equals("/")) {

if (tfield.getText().equals(""))
{
tfield.setText("");
temp = 1;
ch = '/';
}
else
{

x = 0;
y = 0;
temp = Double.parseDouble(tfield.getText());
ch = '/';
tfield.setText("");
}
tfield.requestFocus();

}
if (s.equals("*")) {
if (tfield.getText().equals(""))
{
tfield.setText("");

temp = 1;

ch = '*';
}
else
{
x = 0;
y = 0;

temp = Double.parseDouble(tfield.getText());

ch = '*';
tfield.setText("");
}

tfield.requestFocus();
}

if (s.equals("MC"))
{
m1 = 0;
tfield.setText("");
}

if (s.equals("MR"))
{
tfield.setText("");
tfield.setText(tfield.getText() + m1);

}
if (s.equals("M+"))
{

if (k == 1) {
m1 = Double.parseDouble(tfield.getText());
k++;

}
else
{

m1 += Double.parseDouble(tfield.getText());
tfield.setText("" + m1);
}
}
if (s.equals("M-"))
{
if (k == 1) {

m1 = Double.parseDouble(tfield.getText());
k++;

}
else
{

m1 -= Double.parseDouble(tfield.getText());
tfield.setText("" + m1);
}
}
if (s.equals("Sqrt"))
{
if (tfield.getText().equals(""))
{

tfield.setText("");
}
else
{
a = Math.sqrt(Double.parseDouble(tfield.getText()));
tfield.setText("");
field.setText(tfield.getText() + a);
}
}
if (s.equals("SIN"))

{
if (tfield.getText().equals(""))
{
tfield.setText("");

}
else

{
a = Math.sin(Double.parseDouble(tfield.getText()));
tfield.setText("");

tfield.setText(tfield.getText() + a);
}

}
if (s.equals("COS"))
{
if (tfield.getText().equals(""))
{
tfield.setText("");
}

else
{

a = Math.cos(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText() + a);
}

}
if (s.equals("TAN")) {
if (tfield.getText().equals("")) {
tfield.setText("");
}
else
{

a = Math.tan(Double.parseDouble(tfield.getText()));
tfield.setText("");

tfield.setText(tfield.getText() + a);
}
}
if (s.equals("="))
{

if (tfield.getText().equals(""))
{
tfield.setText("");
}
else
{

temp1 = Double.parseDouble(tfield.getText());
switch (ch)
{
case '+':
result = temp + temp1;
break;
case '-':

result = temp - temp1;


break;
case '/':

result = temp / temp1;

break;
case '*':
result = temp * temp1;
break;
}
tfield.setText("");
tfield.setText(tfield.getText() + result);

z = 1;

}
}

if (s.equals("n!"))
{
if (tfield.getText().equals(""))
{
tfield.setText("");
}

else
{
a = fact(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText() + a);
}
}
tfield.requestFocus();
}

double fact(double x)
{
int er = 0;

if (x < 0)
{

er = 20;
return 0;

}
double i, s = 1;

for (i = 2; i <= x; i += 1.0)


s *= i;
return s;

}
public static void main(String args[])
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

}
catch (Exception e)
{
}
ScientificCalculator f = new ScientificCalculator();
f.setTitle("ScientificCalculator");
f.pack();
f.setVisible(true);

}
}
OUTPUT

b)Decimal Calculator
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
public class DecimalCalculator extends JFrame implements ActionListener
{

JTextField tfield;
double temp,temp1,result,a,ml;
static double m1,m2;
int k=1,x=0,y=0,z=0;
char ch;

JButton
b1, b2, b3, b4, b5, b6, b7, b8, b9, zero, clr, plus, min, div, rec, mul, eq, addsub, dot, mr, mc, mp,
mm, sqrt;
Container cont;

JPanel textpanel,buttonpanel;
DecimalCalculator()
{
cont=getContentPane();
cont.setLayout(new BorderLayout());
JPanel textpanel=new JPanel();

tfield=new JTextField(25);

tfield.setHorizontalAlignment(SwingConstants.RIGHT);
tfield.addKeyListener(new KeyAdapter()
{
public void keyTyped(KeyEvent keyevent)
{

char c=keyevent.getKeyChar();

if(c>='0'&&c<='9')
{
}
else
{

keyevent.consume();
}
}
});

textpanel.add(tfield);

buttonpanel=new JPanel();
buttonpanel.setLayout(new GridLayout(8,4,2,2));
boolean t=true;

mr=new JButton("MR");
buttonpanel.add(mr);
mr.addActionListener(this);
mc=new JButton("MC");
buttonpanel.add(mc);
mc.addActionListener(this);
mp=new JButton("M+");
buttonpanel.add(mp);
mp.addActionListener(this);
mm=new JButton("M-");
buttonpanel.add(mm);
mm.addActionListener(this);
b1=new JButton("1");
buttonpanel.add(b1);
b1.addActionListener(this);
b2=new JButton("2");
buttonpanel.add(b2);
b2.addActionListener(this);
b3=new JButton("3");
buttonpanel.add(b3);
b3.addActionListener(this);
b4=new JButton("4");
buttonpanel.add(b4);
b4.addActionListener(this);
b5=new JButton("5");
buttonpanel.add(b5);
b5.addActionListener(this);
b6=new JButton("6");
buttonpanel.add(b6);
b6.addActionListener(this);
b7=new JButton("7");
buttonpanel.add(b7);
b7.addActionListener(this);
b8=new JButton("8");
buttonpanel.add(b8);
b8.addActionListener(this);
b9=new JButton("9");
buttonpanel.add(b9);
b9.addActionListener(this);
zero=new JButton("0");
buttonpanel.add(zero);
zero.addActionListener(this);
plus=new JButton("+");
buttonpanel.add(plus);
plus.addActionListener(this);
min=new JButton("-");
buttonpanel.add(min);
min.addActionListener(this);
mul=new JButton("*");
buttonpanel.add(mul);
mul.addActionListener(this);
div=new JButton("/");
buttonpanel.add(div);
div.addActionListener(this);
addsub=new JButton("+/-");
buttonpanel.add(addsub);
addsub.addActionListener(this);
dot=new JButton(".");
buttonpanel.add(dot);
dot.addActionListener(this);
eq=new JButton("=");
buttonpanel.add(eq);
eq.addActionListener(this);
rec=new JButton("1/x");
buttonpanel.add(rec);
rec.addActionListener(this);
sqrt=new JButton("Sqrt");
buttonpanel.add(sqrt);
sqrt.addActionListener(this);
clr=new JButton("AC");
buttonpanel.add(clr);
clr.addActionListener(this);
cont.add("Center",buttonpanel);
cont.add("North",textpanel);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)

{
String s=e.getActionCommand();
if(s.equals("1"))
{

if(z==0)
{

tfield.setText(tfield.getText()+"1");
}
else
{
tfield.setText("");
tfield.setText(tfield.getText()+"1");
z=0;

}
}
if(s.equals("2"))
{
if(z==0)

{
tfield.setText(tfield.getText()+"2");
}
else
{
tfield.setText("");
tfield.setText(tfield.getText()+"2");

z=0;

}
}
if(s.equals("3"))
{
if(z==0)

{
tfield.setText(tfield.getText()+"3");

}
else
{
tfield.setText("");
tfield.setText(tfield.getText()+"3");
z=0;

}
}
if(s.equals("4"))
{
if(z==0)
{

tfield.setText(tfield.getText()+"4");
}
else
{
tfield.setText("");
tfield.setText(tfield.getText()+"4");

z=0;

}
}
if(s.equals("5"))
{
if(z==0)
{

tfield.setText(tfield.getText()+"5");
}

else
{

tfield.setText("");
tfield.setText(tfield.getText()+"5"); z=0;
}

}
if(s.equals("6"))
{
if(z==0)
{
tfield.setText(tfield.getText()+"6");

}
else
{

tfield.setText("");
tfield.setText(tfield.getText()+"6");
z=0;

}
}
if(s.equals("7"))
{

if(z==0)
{
tfield.setText(tfield.getText()+"7");
}

else
{

tfield.setText("");
tfield.setText(tfield.getText()+"7");
z=0;
}
}

if(s.equals("8"))

{
if(z==0)
{
tfield.setText(tfield.getText()+"8");
}

else
{
tfield.setText("");
tfield.setText(tfield.getText()+"8");
z=0;
}
}

if(s.equals("9"))
{

if(z==0)
{

tfield.setText(tfield.getText()+"9");
}

else
{

tfield.setText("");
tfield.setText(tfield.getText()+"9");
z=0;
}
}

if(s.equals("0"))

{
if(z==0)
{
tfield.setText(tfield.getText()+"0");
}

else
{
tfield.setText("");
tfield.setText(tfield.getText()+"0");
z=0;
}
}

if(s.equals("AC"))
{
tfield.setText("");

x=0;
y=0;
z=0;
}

if(s.equals("log"))
{

if(tfield.getText().equals(""))
{
tfield.setText("");
}
else

{
a=Math.log(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText()+a);

}
}

if(s.equals("1/x"))
{
if(tfield.getText().equals(""))

{
tfield.setText("");
}
else

{
a=1/(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText()+a);

}
}
if(s.equals("+/-"))

{
if(x==0)
{

tfield.setText("-"+tfield.getText());
x=1;
}
else
{
tfield.setText(tfield.getText());
}
}
if(s.equals("."))
{

if(y==0)
{

tfield.setText(tfield.getText()+".");
y=1;
}
else
{
tfield.setText(tfield.getText());
}
}

if(s.equals("+"))
{
if(tfield.getText().equals(""))

tfield.setText("");
temp=0;
ch='+';
}
else
{

temp=Double.parseDouble(tfield.getText());
tfield.setText("");
ch='+';
y=0;
x=0;

}
tfield.requestFocus();
}
if(s.equals("-"))

{
if(tfield.getText().equals(""))
{
tfield.setText("");
temp=0;

ch='-';
}
else

{
temp=Double.parseDouble(tfield.getText());
tfield.setText("");
ch='-';

y=0;
x=0;

}
tfield.requestFocus();
}
if(s.equals("/"))
{
if(tfield.getText().equals(""))
{

tfield.setText("");

temp=1;
ch='/';
}
else
{
temp=Double.parseDouble(tfield.getText());

tfield.setText("");
ch='/';
y=0;
x=0;
}
tfield.requestFocus();

}
if(s.equals("*"))
{

if(tfield.getText().equals(""))
{

tfield.setText("");
temp=1;
ch='*';
}
else

temp=Double.parseDouble(tfield.getText());
tfield.setText("");

ch='*';
y=0;

x=0;

}
tfield.requestFocus();

}
if(s.equals("MC"))
{
ml=0;

tfield.setText("");
}
if(s.equals("MR"))
{

tfield.setText("");
tfield.setText(tfield.getText()+ml);
}

if(s.equals("M+"))
{

if(k==1)
{

ml=Double.parseDouble(tfield.getText());
k++;
}

else
{
ml+=Double.parseDouble(tfield.getText());
tfield.setText(""+ml);

}
}

if(s.equals("M-"))
{
if(k==1)
{
ml=Double.parseDouble(tfield.getText());
k++;
}
else
{
ml-=Double.parseDouble(tfield.getText());
tfield.setText(""+ml);

}
}
if(s.equals("Sqrt"))

{
if(tfield.getText().equals(""))

{
tfield.setText("");
}
else
{

a=Math.sqrt(Double.parseDouble(tfield.getText()));
tfield.setText("");
tfield.setText(tfield.getText()+a);
}
}
if(s.equals("="))

{
if(tfield.getText().equals(""))
{
tfield.setText("");
}
else
{

temp1=Double.parseDouble(tfield.getText());
switch(ch)
{
case '+':
result=temp+temp1;
break;
case '-':

result=temp-temp1;
break;

case '/':
result=temp/temp1;
break;
case '*':

result=temp*temp1;
break;

}
tfield.setText("");
tfield.setText(tfield.getText()+result);

z=1;
}
}
}

public static void main(String args[])


{
DecimalCalculator d;

d=new DecimalCalculator();
d.setTitle("Decimal calculator");
d.pack();
d.setVisible(true);
}
}
RESULT
MINI PROJECT
FEE MANAGEMENT SYSTEM
MINI PROJECT- FEE MANAGEMENT SYSTEM

Abstract:
The main objective of the project is to identify the fess defaulters in the
particular instituition.It can be used for other bill due payments also.the project is
divided into various modules like:
1. Admin
2. Accountant
3. Student
4. Fees Structure
5. Due Management
6. DAO details
And the over all account section is managed by the administrative system and all
essential curriculum structure of the person course or package taken.
AccountantDao .java
package com.javatpoint.feereport;
import java.sql.Connection;
import java.sql.DriverManager;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

import java.util.ArrayList;
import java.util.List;
public class AccountantDao {
public static Connection getCon(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","","");
}
catch(Exception e){System.out.println(e);}

return con;
}

public static boolean validate(String name,String password){


boolean status=false;
try{
Connection con=getCon();
PreparedStatement ps=con.prepareStatement("select * from feereport_accountant where name=?
and password=?");
ps.setString(1,name);
ps.setString(2,password);
ResultSet rs=ps.executeQuery();
status=rs.next();
con.close();

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

}
public static int save(Accountant a)
{

int status=0;
try{

Connection con=getCon();PreparedStatement ps=con.prepareStatement("insert into


feereport_accountant(name,password,email,contactno) values(?,?,?,?)");
ps.setString(1,a.getName());
ps.setString(2,a.getPassword());

ps.setString(3,a.getEmail());
ps.setString(4,a.getContactno());

status=ps.executeUpdate();
con.close();

}catch(Exception e){System.out.println(e);}
return status;
}
public static List<Accountant> view(){
List<Accountant> list=new ArrayList<>();
try{
Connection con=getCon();
PreparedStatement ps=con.prepareStatement("select * from feereport_accountant");

ResultSet rs=ps.executeQuery();
while(rs.next()){
Accountant a=new Accountant();
a.setId(rs.getInt(1));
a.setName(rs.getString(2));
a.setPassword(rs.getString(3));
a.setEmail(rs.getString(4));
a.setContactno(rs.getString(5));
list.add(a);
}
con.close();
}catch(Exception e){System.out.println(e);}
return list;

}
}

AccountantLogin.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;

import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Color;
import java.awt.Font;

import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class AccountantLogin extends JFrame {

static AccountantLogin frame;

private JPanel contentPane;


private JTextField textField;
private JPasswordField passwordField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new AccountantLogin();

frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();}}});
}

public AccountantLogin() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);

contentPane = new JPanel();


contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAccountantLogin = new JLabel("Accountant Login");
lblAccountantLogin.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblAccountantLogin.setForeground(Color.DARK_GRAY);

JLabel lblName = new JLabel("Name:");


textField = new JTextField();
textField.setColumns(10);

JLabel lblPassword = new JLabel("Password:");


passwordField = new JPasswordField();
JButton btnLogin = new JButton("login");

btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String name=textField.getText();

String password=String.valueOf(passwordField.getPassword());
boolean status=AccountantDao.validate(name, password);
if(status){

AccountantSection.main(new String[]{});
frame.dispose();
}
Else
{

JOptionPane.showMessageDialog(AccountantLogin.this,"Sorry, username or password


error!","Login error!",JOptionPane.ERROR_MESSAGE);
}}});
JButton btnBack = new JButton("back");
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(28)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblPassword)

.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblName)

.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(76)
.addComponent(lblAccountantLogin))
.addGroup(gl_contentPane.createSequentialGroup()

.addGap(54)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addComponent(passwordField)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)))))))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(158)

.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 81,


GroupLayout.PREFERRED_SIZE)
.addGap(52)
.addComponent(btnBack)))
.addContainerGap(78, Short.MAX_VALUE))
);

gl_contentPane.setVerticalGroup(

gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblAccountantLogin)

.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblName)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(18)

.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblPassword)
.addComponent(passwordField, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 32,
GroupLayout.PREFERRED_SIZE)
.addComponent(btnBack))

.addContainerGap(96, Short.MAX_VALUE))
);
contentPane.setLayout(gl_contentPane);
}}

AccountantSection.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;

import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;
public class AccountantSection extends JFrame {
static AccountantSection frame;
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {

public void run() {

try {
frame = new AccountantSection();
frame.setVisible(true);
} catch (Exception e) {

e.printStackTrace();
}}});
}

public AccountantSection() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 423);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);

JButton btnNewButton = new JButton("Add Student");


btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AddStudent.main(new String[]{});
frame.disable();

}});

JLabel lblAccountantSection = new JLabel("Accountant Section");


lblAccountantSection.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblAccountantSection.setForeground(Color.DARK_GRAY);
JButton btnViewStudent = new JButton("View Student");
btnViewStudent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

ViewStudent.main(new String[]{});
}
});

JButton btnEditStudent = new JButton("Edit Student");

btnEditStudent.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
EditStudent.main(new String[]{});
frame.dispose();
}});

JButton btnDueFee = new JButton("Due Fee");


btnDueFee.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DueFee.main(new String[]{});
}});
JButton btnLogout = new JButton("Logout");
btnLogout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
FeeReport.main(new String[]{});
frame.dispose();
}});

GroupLayout gl_contentPane = new GroupLayout(contentPane);


gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(136)

.addComponent(lblAccountantSection))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(52)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(btnEditStudent, GroupLayout.PREFERRED_SIZE, 133,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(btnDueFee, GroupLayout.PREFERRED_SIZE, 133,
GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()

.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 133,


GroupLayout.PREFERRED_SIZE)
.addGap(53)

.addComponent(btnViewStudent, GroupLayout.PREFERRED_SIZE, 133,


GroupLayout.PREFERRED_SIZE))))
.addGroup(gl_contentPane.createSequentialGroup()

.addGap(144)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 133,
GroupLayout.PREFERRED_SIZE)))
.addContainerGap(53, Short.MAX_VALUE)));
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(7)
.addComponent(lblAccountantSection)

.addGap(25)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(btnNewButton, GroupLayout.PREFERRED_SIZE, 36,
GroupLayout.PREFERRED_SIZE)
.addComponent(btnViewStudent, GroupLayout.PREFERRED_SIZE, 36,
GroupLayout.PREFERRED_SIZE))
.addGap(35)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(btnEditStudent, GroupLayout.PREFERRED_SIZE, 36,
GroupLayout.PREFERRED_SIZE)
.addComponent(btnDueFee, GroupLayout.PREFERRED_SIZE, 36,
GroupLayout.PREFERRED_SIZE))
.addGap(36)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 36,
GroupLayout.PREFERRED_SIZE)
.addContainerGap(138, Short.MAX_VALUE)));
contentPane.setLayout(gl_contentPane);
}
}

AddAccountant.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;

import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
import javax.swing.LayoutStyle.ComponentPlacement;

import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class AddAccountant extends JFrame
{

static AddAccountant frame;


private JPanel contentPane;

private JTextField textField;

private JPasswordField passwordField;

private JTextField textField_1;


private JTextField textField_2;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {

try {
frame = new AddAccountant();
frame.setVisible(true);

} catch (Exception e) {
e.printStackTrace();

}}});
}
public AddAccountant()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);

contentPane = new JPanel();


contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);

JLabel lblAddAccountant = new JLabel("Add Accountant");


lblAddAccountant.setForeground(Color.DARK_GRAY);
lblAddAccountant.setFont(new Font("Tahoma", Font.PLAIN, 20));

JLabel lblName = new JLabel("Name:");

JLabel lblPassword = new JLabel("Password:");


JLabel lblEmail = new JLabel("Email:");

JLabel lblContactNo = new JLabel("Contact No:");


textField = new JTextField();
textField.setColumns(10);
passwordField = new JPasswordField();
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setColumns(10);
JButton btnAddAccountant = new JButton("Add Accountant");
btnAddAccountant.addActionListener(new ActionListener()

public void actionPerformed(ActionEvent e) {


String name=textField.getText();
char ch[]=passwordField.getPassword();
String password=String.valueOf(ch);
String email=textField_1.getText();
String contactno=textField_2.getText();
Accountant a=new Accountant(name,password,email,contactno);
int status=AccountantDao.save(a);
if(status>0){
JOptionPane.showMessageDialog(AddAccountant.this,"Accountant added successfully!");
textField.setText("");textField_1.setText("");textField_2.setText("");
passwordField.setText("");
}else{
JOptionPane.showMessageDialog(AddAccountant.this,"Sorry, Unable to add Accountant!");
}}});

JButton btnBack = new JButton("Back");


btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AdminSection.main(new String[]{});
frame.dispose();
}});
GroupLayout gl_contentPane = new GroupLayout(contentPane);

gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)

.addComponent(lblName, GroupLayout.PREFERRED_SIZE, 82,


GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword, GroupLayout.PREFERRED_SIZE, 82,
GroupLayout.PREFERRED_SIZE)
.addComponent(lblEmail, GroupLayout.PREFERRED_SIZE, 82,
GroupLayout.PREFERRED_SIZE)
.addComponent(lblContactNo, GroupLayout.PREFERRED_SIZE, 82,
GroupLayout.PREFERRED_SIZE))
.addGap(44)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)

.addComponent(textField_2, GroupLayout.PREFERRED_SIZE, 187,


GroupLayout.PREFERRED_SIZE)
.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, 187,
GroupLayout.PREFERRED_SIZE)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)

.addComponent(textField, GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)


.addComponent(passwordField)))
.addContainerGap(101, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(155)
.addComponent(btnAddAccountant, GroupLayout.PREFERRED_SIZE, 127,
GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED, 69, Short.MAX_VALUE)
.addComponent(btnBack)

.addGap(18))
.addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
.addContainerGap(163, Short.MAX_VALUE)
.addComponent(lblAddAccountant)
.addGap(122)));
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblAddAccountant)

.addGap(11)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblName)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(18)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblPassword)

.addComponent(passwordField, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEmail)
.addComponent(textField_1, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblContactNo)
.addComponent(textField_2, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(btnAddAccountant, GroupLayout.DEFAULT_SIZE, 41, Short.MAX_VALUE)
.addComponent(btnBack)).addContainerGap()));
contentPane.setLayout(gl_contentPane);

}
}

AddStudent.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;

import java.awt.Color;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;

import javax.swing.JTextField;
import javax.swing.JTextPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
public class AddStudent extends JFrame {
static AddStudent frame;

private JPanel contentPane;


private JTextField textField;
private JTextField textField_1;

private JTextField textField_2;


private JTextField textField_3;

private JTextField textField_4;


private JTextField textField_5;
private JTextField textField_6;

private JTextField textField_7;


private JTextField textField_8;

private JTextField textField_9;


JTextArea textArea;
public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {
public void run() {

try {
frame = new AddStudent();
frame.setVisible(true);
}
catch (Exception e) {

e.printStackTrace();
}}});
}

public AddStudent() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 503);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAddAccountant = new JLabel("Add Student");
lblAddAccountant.setForeground(Color.DARK_GRAY);
lblAddAccountant.setFont(new Font("Tahoma", Font.PLAIN, 20));
JLabel lblName = new JLabel("Name:");

JLabel lblEmail = new JLabel("Email:");


JLabel lblCourse = new JLabel("Course:");
JLabel lblFee = new JLabel("Fee:");
JLabel lblPaid = new JLabel("Paid:");
JLabel lblDue = new JLabel("Due:");

JLabel lblAddress = new JLabel("Address:");


JLabel lblCity = new JLabel("City:");

JLabel lblState = new JLabel("State:");


JLabel lblCountry = new JLabel("Country:");
JLabel lblContactNo = new JLabel("Contact No:");

JButton btnAddAccountant = new JButton("Add Student");


btnAddAccountant.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

String name=textField.getText();
String email=textField_1.getText();
String course=textField_2.getText();

int fee=Integer.parseInt(textField_3.getText());
int paid=Integer.parseInt(textField_4.getText());
int due=Integer.parseInt(textField_5.getText());
String address=textArea.getText();

String city=textField_6.getText();
String state=textField_7.getText();
String country=textField_8.getText();
String contactno=textField_9.getText();

Student s=new Student(name,email,course,fee,paid,due,address,city,state,country,contactno);


int status=StudentDao.save(s);
if(status>0){
JOptionPane.showMessageDialog(AddStudent.this,"Student added successfully!");
textField.setText("");textField_1.setText("");textField_2.setText("");
textField_3.setText("");textField_4.setText("");textField_5.setText("");
textField_6.setText("");textField_7.setText("");textField_8.setText("");
textField_9.setText("");textArea.setText("");
}else{

JOptionPane.showMessageDialog(AddStudent.this,"Sorry, Unable to add student!");


}}});
textField = new JTextField();

textField.setColumns(10);
textField_1 = new JTextField();
textField_1.setColumns(10);
textField_2 = new JTextField();
textField_2.setColumns(10);
textField_3 = new JTextField();
textField_3.setColumns(10);
textField_4 = new JTextField();
textField_4.setColumns(10);
textField_5 = new JTextField();
textField_5.setColumns(10);
textField_6 = new JTextField();
textField_6.setColumns(10);
textField_7 = new JTextField();

textField_7.setColumns(10);
textField_8 = new JTextField();

textField_8.setColumns(10);
textField_9 = new JTextField();
textField_9.setColumns(10);

textArea = new JTextArea();


textArea.setRows(3);

textArea.setColumns(20);

JButton btnBack = new JButton("back");


btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
AccountantSection.main(new String[]{});
frame.dispose();
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);

gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()

.addGap(142)
.addComponent(lblAddAccountant))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblName)

.addComponent(lblCourse, GroupLayout.PREFERRED_SIZE, 48,


GroupLayout.PREFERRED_SIZE)
.addComponent(lblFee, GroupLayout.PREFERRED_SIZE, 31,
GroupLayout.PREFERRED_SIZE)
.addComponent(lblPaid, GroupLayout.PREFERRED_SIZE, 31,
GroupLayout.PREFERRED_SIZE)
.addComponent(lblDue, GroupLayout.PREFERRED_SIZE, 31,
GroupLayout.PREFERRED_SIZE)

.addComponent(lblAddress, GroupLayout.PREFERRED_SIZE, 64,


GroupLayout.PREFERRED_SIZE)
.addComponent(lblEmail, GroupLayout.PREFERRED_SIZE, 56,
GroupLayout.PREFERRED_SIZE))
.addGap(33)

.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)

.addComponent(textArea, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,


GroupLayout.PREFERRED_SIZE)
.addComponent(textField_5, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
.addComponent(textField_4, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
.addComponent(textField_3, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)

.addComponent(textField_2, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)


.addComponent(textField_1, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
.addComponent(textField_7, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)
.addComponent(textField_8, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)

.addComponent(textField_9, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE)


.addComponent(textField_6, GroupLayout.DEFAULT_SIZE, 193, Short.MAX_VALUE))))
.addContainerGap(124, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblContactNo)

.addContainerGap(356, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()

.addContainerGap()
.addComponent(lblCountry, GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
.addGap(350))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()

.addComponent(lblCity, GroupLayout.PREFERRED_SIZE, 31,


GroupLayout.PREFERRED_SIZE)
.addContainerGap(383, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()

.addGap(128)
.addComponent(btnAddAccountant, GroupLayout.PREFERRED_SIZE, 145,
GroupLayout.PREFERRED_SIZE)
.addGap(18)

.addComponent(btnBack)
.addContainerGap(44, Short.MAX_VALUE))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblState, GroupLayout.PREFERRED_SIZE, 50,
GroupLayout.PREFERRED_SIZE)
.addContainerGap(364, Short.MAX_VALUE))
);

gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAddAccountant)
.addGap(18)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblName)

.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,


GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEmail)
.addComponent(textField_1, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblCourse)

.addComponent(textField_2, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)

.addComponent(lblFee)
.addComponent(textField_3, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)

.addComponent(lblPaid)
.addComponent(textField_4, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblDue)
.addComponent(textField_5, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblAddress)

.addComponent(textArea, GroupLayout.PREFERRED_SIZE, 49,


GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)

.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblCity)

.addGap(18))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(textField_6, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)))

.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblState)
.addComponent(textField_7, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)

.addComponent(lblCountry)
.addComponent(textField_8, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)

.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)

.addComponent(lblContactNo)
.addComponent(textField_9, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(7)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)

.addComponent(btnAddAccountant, GroupLayout.PREFERRED_SIZE, 38,


GroupLayout.PREFERRED_SIZE)
.addComponent(btnBack))
.addContainerGap())
);

contentPane.setLayout(gl_contentPane);
}
}

AdminLogin.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;

import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class AdminLogin extends JFrame {
static AdminLogin frame;

private JPanel contentPane;


private JTextField textField;
private JPasswordField passwordField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {

frame = new AdminLogin();

frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();
}}});
}
public AdminLogin() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);

contentPane = new JPanel();


contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblAdminLogin = new JLabel("Admin Login");
lblAdminLogin.setForeground(Color.DARK_GRAY);
lblAdminLogin.setFont(new Font("Tahoma", Font.PLAIN, 20));

JLabel lblName = new JLabel("Name:");


JLabel lblPassword = new JLabel("Password:");
textField = new JTextField();

textField.setColumns(10);
passwordField = new JPasswordField();

JButton btnLogin = new JButton("login");


btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name=textField.getText();
char ch[]=passwordField.getPassword();
String password=String.valueOf(ch);

if(name.equals("admin")&&password.equals("admin123")){
String s[]={};
AdminSection.main(s);
frame.dispose();
}else{

JOptionPane.showMessageDialog(AdminLogin.this,"Sorry, username or password error!");


textField.setText("");passwordField.setText("");
}}});

GroupLayout gl_contentPane = new GroupLayout(contentPane);


gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(180)

.addComponent(lblAdminLogin))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(25)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)

.addComponent(lblName)
.addComponent(lblPassword))

.addGap(58)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
.addComponent(passwordField)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)))
.addGroup(gl_contentPane.createSequentialGroup()

.addGap(177)
.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 86,
GroupLayout.PREFERRED_SIZE)))
.addContainerGap(111, Short.MAX_VALUE)));
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAdminLogin)
.addGap(29)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblName)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addGap(27)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)

.addComponent(passwordField, GroupLayout.PREFERRED_SIZE,
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblPassword))
.addGap(36)

.addComponent(btnLogin, GroupLayout.PREFERRED_SIZE, 33,


GroupLayout.PREFERRED_SIZE)
.addContainerGap(51, Short.MAX_VALUE))

);
contentPane.setLayout(gl_contentPane);

}
}

AdminSection.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;

import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;

import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;
import java.awt.event.ActionListener;

import java.util.List;

import java.awt.event.ActionEvent;
public class AdminSection extends JFrame {

static AdminSection frame;

private JPanel contentPane;


JScrollPane sp;
public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {
public void run() {

try {
frame = new AdminSection();
frame.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}}});
}
public AdminSection() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);

contentPane = new JPanel();


contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);
JLabel lblAdminSection = new JLabel("Admin Section");

lblAdminSection.setForeground(Color.DARK_GRAY);
lblAdminSection.setFont(new Font("Tahoma", Font.PLAIN, 20));
JButton btnAddAccountant = new JButton("Add Accountant");

btnAddAccountant.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

AddAccountant.main(new String[]{});
frame.dispose();}});
JButton btnViewAccountant = new JButton("View Accountant");
btnViewAccountant.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ViewAccountant.main(new String[]{});

}});

JButton btnLogout = new JButton("Logout");


btnLogout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FeeReport.main(new String[]{});
frame.dispose();
}});

GroupLayout gl_contentPane = new GroupLayout(contentPane);


gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(161)

.addComponent(lblAdminSection))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(149)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(btnViewAccountant, GroupLayout.PREFERRED_SIZE, 130,
GroupLayout.PREFERRED_SIZE)
.addComponent(btnAddAccountant, GroupLayout.PREFERRED_SIZE, 130,
GroupLayout.PREFERRED_SIZE)
.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 130,
GroupLayout.PREFERRED_SIZE))))
.addContainerGap(136, Short.MAX_VALUE))

);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblAdminSection)

.addGap(29)

.addComponent(btnAddAccountant, GroupLayout.PREFERRED_SIZE, 34,


GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(btnViewAccountant, GroupLayout.PREFERRED_SIZE, 34,
GroupLayout.PREFERRED_SIZE)
.addGap(18)

.addComponent(btnLogout, GroupLayout.PREFERRED_SIZE, 34,


GroupLayout.PREFERRED_SIZE)
.addContainerGap(59, Short.MAX_VALUE))

);
contentPane.setLayout(gl_contentPane);
}}

DueFee.java

package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.util.List;
import javax.swing.JFrame;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.border.EmptyBorder;
public class DueFee extends JFrame {
static DueFee frame;
public DueFee() {

//Code to view data in JTable


List<Student> list=StudentDao.due();
int size=list.size();

String data[][]=new String[size][12];


int row=0;
for(Student s:list){
data[row][0]=String.valueOf(s.getRollno());
data[row][1]=s.getName();
data[row][2]=s.getEmail();
data[row][3]=s.getCourse();

data[row][4]=String.valueOf(s.getFee());
data[row][5]=String.valueOf(s.getPaid());

data[row][6]=String.valueOf(s.getDue());
data[row][7]=s.getAddress();

data[row][8]=s.getCity();

data[row][9]=s.getState();
data[row][10]=s.getCountry();
data[row][11]=s.getContactno();
row++;
}
String
columnNames[]={"Rollno","Name","Email","Course","Fee","Paid","Due","Address","City","Sta
te","Country","Contact No"};

JTable jt=new JTable(data,columnNames);


JScrollPane sp=new JScrollPane(jt);
add(sp);

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 800, 400);

}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new DueFee();

frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();

}
}});
}}

FeeReport.java
package com.javatpoint.feereport;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import javax.swing.GroupLayout;

import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class FeeReport extends JFrame {
static FeeReport frame;

private JPanel contentPane;


public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {
public void run() {

try {
frame = new FeeReport();
frame.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}}});
}

public FeeReport() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setForeground(Color.DARK_GRAY);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);

JLabel lblFeeReport = new JLabel("Fee Report");


lblFeeReport.setFont(new Font("Tahoma", Font.PLAIN, 20));
JButton btnAdminLogin = new JButton("Admin Login");
btnAdminLogin.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {


AdminLogin.main(new String[]{});

frame.dispose();
}});

JButton btnAccountantLogin = new JButton("Accountant Login");


btnAccountantLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
AccountantLogin.main(new String[]{});
frame.dispose();
}
});
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)

.addGroup(gl_contentPane.createSequentialGroup()
.addGap(143)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(btnAccountantLogin, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE,
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)

.addComponent(btnAdminLogin, GroupLayout.DEFAULT_SIZE, 132, Short.MAX_VALUE)

.addComponent(lblFeeReport)))
.addContainerGap(210, Short.MAX_VALUE)));
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblFeeReport)
.addGap(42)

.addComponent(btnAdminLogin, GroupLayout.PREFERRED_SIZE, 32,


GroupLayout.PREFERRED_SIZE)
.addGap(30)
.addComponent(btnAccountantLogin, GroupLayout.PREFERRED_SIZE, 31,
GroupLayout.PREFERRED_SIZE)
.addContainerGap(91, Short.MAX_VALUE))

);
contentPane.setLayout(gl_contentPane);
}}

Student.java
package com.javatpoint.feereport;
public class Student {
private int rollno;
private String name,email,course;

private int fee,paid,due;


private String address,city,state,country,contactno;
public Student() {}
public Student(String name, String email, String course, int fee, int paid, int due, String address,
String city,
String state, String country, String contactno) {

super();
this.name = name;
this.email = email;

this.course = course;
this.fee = fee;

this.paid = paid;
this.due = due;
this.address = address;

this.city = city;
this.state = state;

this.country = country;

this.contactno = contactno;
}
public Student(int rollno, String name, String email, String course, int fee, int paid, int due,
String address,
String city, String state, String country, String contactno) {

super();

this.rollno = rollno;

this.name = name;
this.email = email;
this.course = course;
this.fee = fee;
this.paid = paid;
this.due = due;
this.address = address;
this.city = city;
this.state = state;
this.country = country;
this.contactno = contactno;
}
public int getRollno() {
return rollno;
}

public void setRollno(int rollno) {

this.rollno = rollno;
}

public String getName() {


return name;

}
public void setName(String name) {
this.name = name;
}
public String getEmail() {

return email;

}
public void setEmail(String email) {
this.email = email;

}
public String getCourse() {
return course;

}
public void setCourse(String course) {
this.course = course;

}
public int getFee() {
return fee;
}
public void setFee(int fee) {
this.fee = fee;
}
public int getPaid() {
return paid;
}

public void setPaid(int paid) {


this.paid = paid;

}
public int getDue() {
return due;
}
public void setDue(int due) {

this.due = due;

}
public String getAddress() {
return address;

}
public void setAddress(String address) {
this.address = address;

}
public String getCity() {
return city;

}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}

public String getCountry() {


return country;

}
public void setCountry(String country) {
this.country = country;
}
public String getContactno() {

return contactno;

}
public void setContactno(String contactno) {
this.contactno = contactno;

}}

StudentDao.java
package com.javatpoint.feereport;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class StudentDao {

public static int save(Student s){


int status=0;
try{
Connection con=AccountantDao.getCon();
PreparedStatement ps=con.prepareStatement("insert into
feereport_student(name,email,course,fee,paid,due,address,city,state,country,contactno)
values(?,?,?,?,?,?,?,?,?,?,?)");

ps.setString(1,s.getName());
ps.setString(2,s.getEmail());
ps.setString(3, s.getCourse());
ps.setInt(4,s.getFee());
ps.setInt(5,s.getPaid());
ps.setInt(6,s.getDue());
ps.setString(7,s.getAddress());
ps.setString(8,s.getCity());
ps.setString(9,s.getState());
ps.setString(10,s.getCountry());
ps.setString(11,s.getContactno());
status=ps.executeUpdate();
con.close();

}catch(Exception e){System.out.println(e);}
return status;
}
public static int update(Student s){
int status=0;
try{
Connection con=AccountantDao.getCon();
PreparedStatement ps=con.prepareStatement("update feereport_student set
name=?,email=?,course=?,fee=?,paid=?,due=?,address=?,city=?,state=?,country=?,contactno=?
where rollno=?");

ps.setString(1,s.getName());
ps.setString(2,s.getEmail());
ps.setString(3, s.getCourse());

ps.setInt(4,s.getFee());

ps.setInt(5,s.getPaid());
ps.setInt(6,s.getDue());
ps.setString(7,s.getAddress());
ps.setString(8,s.getCity());

ps.setString(9,s.getState());
ps.setString(10,s.getCountry());

ps.setString(11,s.getContactno());
ps.setInt(12,s.getRollno());
status=ps.executeUpdate();

con.close();

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

}
public static List<Student> view(){

List<Student> list=new ArrayList<Student>();


try{

Connection con=AccountantDao.getCon();
PreparedStatement ps=con.prepareStatement("select * from feereport_student");
ResultSet rs=ps.executeQuery();
while(rs.next()){

Student s=new Student();


s.setRollno(rs.getInt("rollno"));
s.setName(rs.getString("name"));
s.setEmail(rs.getString("email"));
s.setCourse(rs.getString("course"));
s.setFee(rs.getInt("fee"));
s.setPaid(rs.getInt("paid"));
s.setDue(rs.getInt("due"));
s.setAddress(rs.getString("address"));
s.setCity(rs.getString("city"));
s.setState(rs.getString("state"));

s.setCountry(rs.getString("country"));
s.setContactno(rs.getString("contactno"));

list.add(s);

}
con.close();
}catch(Exception e){System.out.println(e);}
return list;
}

public static Student getStudentByRollno(int rollno){

Student s=new Student();


try{
Connection con=AccountantDao.getCon();
PreparedStatement ps=con.prepareStatement("select * from feereport_student where rollno=?");
ps.setInt(1,rollno);

ResultSet rs=ps.executeQuery();
if(rs.next()){
s.setRollno(rs.getInt("rollno"));
s.setName(rs.getString("name"));
s.setEmail(rs.getString("email"));
s.setCourse(rs.getString("course"));
s.setFee(rs.getInt("fee"));
s.setPaid(rs.getInt("paid"));
s.setDue(rs.getInt("due"));
s.setAddress(rs.getString("address"));
s.setCity(rs.getString("city"));
s.setState(rs.getString("state"));
s.setCountry(rs.getString("country"));
s.setContactno(rs.getString("contactno"));
}
con.close();
}catch(Exception e){System.out.println(e);}
return s;

}
public static List<Student> due(){

List<Student> list=new ArrayList<Student>();


try{

Connection con=AccountantDao.getCon();
PreparedStatement ps=con.prepareStatement("select * from feereport_student where due>0");
ResultSet rs=ps.executeQuery();
while(rs.next()){
Student s=new Student();
s.setRollno(rs.getInt("rollno"));
s.setName(rs.getString("name"));
s.setEmail(rs.getString("email"));
s.setCourse(rs.getString("course"));
s.setFee(rs.getInt("fee"));
s.setPaid(rs.getInt("paid"));

s.setDue(rs.getInt("due"));
s.setAddress(rs.getString("address"));
s.setCity(rs.getString("city"));
s.setState(rs.getString("state"));
s.setCountry(rs.getString("country"));
s.setContactno(rs.getString("contactno"));
list.add(s);

}
con.close();

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

ViewAccountant.java
package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JPanel;

import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.border.EmptyBorder;
public class ViewAccountant extends JFrame {
static ViewAccountant frame;

public ViewAccountant() {
//Code to view data in JTable
List<Accountant> list=AccountantDao.view();
int size=list.size();

String data[][]=new String[size][5];


int row=0;
for(Accountant a:list){
data[row][0]=String.valueOf(a.getId());
data[row][1]=a.getName();
data[row][2]=a.getPassword();
data[row][3]=a.getEmail();
data[row][4]=a.getContactno();
row++;
}

String columnNames[]={"Id","Name","Password","Email","Contact No"};


JTable jt=new JTable(data,columnNames);

JScrollPane sp=new JScrollPane(jt);


add(sp);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 800, 400);
}

public static void main(String[] args) {


EventQueue.invokeLater(new Runnable() {
public void run() {

try {
frame = new ViewAccountant();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();

}}});}}
ViewStudent.java

package com.javatpoint.feereport;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.border.EmptyBorder;
public class ViewStudent extends JFrame {
static ViewStudent frame;
public ViewStudent() {
//Code to view data in JTable
List<Student> list=StudentDao.view();
int size=list.size();
String data[][]=new String[size][12];
int row=0;
for(Student s:list){
data[row][0]=String.valueOf(s.getRollno());
data[row][1]=s.getName();

data[row][2]=s.getEmail();
data[row][3]=s.getCourse();
data[row][4]=String.valueOf(s.getFee());
data[row][5]=String.valueOf(s.getPaid());
data[row][6]=String.valueOf(s.getDue());
data[row][7]=s.getAddress();
data[row][8]=s.getCity();
data[row][9]=s.getState();
data[row][10]=s.getCountry();
data[row][11]=s.getContactno();
row++;

}
String
columnNames[]={"Rollno","Name","Email","Course","Fee","Paid","Due","Address","City","Sta
te","Country","Contact No"};

JTable jt=new JTable(data,columnNames);


JScrollPane sp=new JScrollPane(jt);
add(sp);

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 800, 400);
}

public static void main(String[] args) {


EventQueue.invokeLater(new Runnable() {
public void run() {

try {
frame = new ViewStudent();
frame.setVisible(true);

} catch (Exception e) {
e.printStackTrace();
}}});
}
}
Update information and click on Update Student.
CONCLUSION
Thus a java application to maintain fees due related issues in an institution has been
developed sucessfully

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy