You are on page 1of 22

Ip Project

On
Java Netbeans
&
Mysql

Class XI-B

Made By- Chakshu Goel


Index

● Bill Receipt Printing System


● Bill Calculator
● Calculator
● Commission Calculator
● Digit to Word
● Discount Calculator
● Percentage to Grade
● Rate of Interest Calculator
● Ticket Booking System

Bill Receipt Printing System


Coding Of Project
public class BillPrintable implements Printable {
public int print(Graphics graphics, PageFormat pageFormat,int pageIndex)
throws PrinterException
{
int result = NO_SUCH_PAGE;
if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D) graphics;
double width = pageFormat.getImageableWidth();
g2d.translate((int) pageFormat.getImageableX(),(int)
pageFormat.getImageableY());

FontMetrics metrics=g2d.getFontMetrics(new Font("Arial",Font.BOLD,7));


// int idLength=metrics.stringWidth("000000");
//int idLength=metrics.stringWidth("00");
int idLength=metrics.stringWidth("000");
int amtLength=metrics.stringWidth("000000");
int qtyLength=metrics.stringWidth("00000");
int priceLength=metrics.stringWidth("000000");
int prodLength=(int)width - idLength - amtLength - qtyLength - priceLength-
17;
// int idPosition=0;
// int productPosition=idPosition + idLength + 2;
// int pricePosition=productPosition + prodLength +10;
// int qtyPosition=pricePosition + priceLength + 2;
// int amtPosition=qtyPosition + qtyLength + 2;
int productPosition = 0;
int discountPosition= prodLength+5;
int pricePosition = discountPosition +idLength+10;
int qtyPosition=pricePosition + priceLength + 4;
int amtPosition=qtyPosition + qtyLength;

try{
/*Draw Header*/
int y=20;
int yShift = 10;
int headerRectHeight=15;
int headerRectHeighta=40;

///////////////// Product names Get ///////////


String pn1a=pn1.getText();
String pn2a=pn2.getText();
String pn3a=pn3.getText();
String pn4a=pn4.getText();
///////////////// Product names Get ///////////

///////////////// Product price Get ///////////


int pp1a=Integer.valueOf(pp1.getText());
int pp2a=Integer.valueOf(pp2.getText());
int pp3a=Integer.valueOf(pp3.getText());
int pp4a=Integer.valueOf(pp4.getText());
int sum=pp1a+pp2a+pp3a+pp4a;
///////////////// Product price Get ///////////

g2d.setFont(new Font("Monospaced",Font.PLAIN,9));
g2d.drawString("-------------------------------------",12,y);y+=yShift;
g2d.drawString(" Restaurant Bill Receipt ",12,y);y+=yShift;
g2d.drawString("-------------------------------------",12,y);y+=headerRectHeight;

g2d.drawString("-------------------------------------",10,y);y+=yShift;
g2d.drawString(" Food Name T.Price ",10,y);y+=yShift;
g2d.drawString("-------------------------------------",10,y);y+=headerRectHeight;
g2d.drawString(" "+pn1a+" "+pp1a+" ",10,y);y+=yShift;
g2d.drawString(" "+pn2a+" "+pp2a+" ",10,y);y+=yShift;
g2d.drawString(" "+pn3a+" "+pp3a+" ",10,y);y+=yShift;
g2d.drawString(" "+pn4a+" "+pp4a+" ",10,y);y+=yShift;
g2d.drawString("-------------------------------------",10,y);y+=yShift;
g2d.drawString(" Total amount: "+sum+" ",10,y);y+=yShift;
g2d.drawString("-------------------------------------",10,y);y+=yShift;
g2d.drawString(" Free Home Delivery ",10,y);y+=yShift;
g2d.drawString(" 03111111111 ",10,y);y+=yShift;
g2d.drawString("*************************************",10,y);y+=yShift;
g2d.drawString(" THANKS TO VISIT OUR Store ",10,y);y+=yShift;
g2d.drawString("*************************************",10,y);y+=yShift;
// g2d.setFont(new Font("Monospaced",Font.BOLD,10));
// g2d.drawString("Customer Shopping Invoice", 30,y);y+=yShift;
}
catch(Exception r){
r.printStackTrace();
}

result = PAGE_EXISTS;
}
return result;
}
}
● Print Receipt Button
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new BillPrintable(),getPageFormat(pj));
try {
pj.print();

}
catch (PrinterException ex) {
ex.printStackTrace();
}

Bill Calculator
Coding Of Project
● Calculate Discount Button
double dis = 0;
double amt = Double.parseDouble(jTextField2.getText());
if(platRB.isSelected()== true)
dis = amt*0.20;
else if(silvRB.isSelected()== true)
dis = amt*0.15;
else
dis = amt*0.10;
jTextField3.setText(""+dis);
double add = 0;
if(amt>25000)
add = amt*0.05;
jTextField4.setText(""+add);
jToggleButton2.setEnabled(true);
● Calculate Net Amount Button
double TotalCost = Double.parseDouble(jTextField2.getText());
double Offer = Double.parseDouble(jTextField3.getText());
double AdditionalOffer = Double.parseDouble(jTextField4.getText());
double netAmount = TotalCost - Offer - AdditionalOffer;
jTextField5.setText(""+netAmount);

Calculator
Coding of Project
● Plus Button
double a,b,t;
a=Double.parseDouble(jTextField1.getText());
b=Double.parseDouble(jTextField2.getText());
t=a+b;
jTextField3.setText(""+t);

● Minus Button
double a,b,t;
a=Double.parseDouble(jTextField1.getText());
b=Double.parseDouble(jTextField2.getText());
t=a-b;
jTextField3.setText(""+t);

● Multiply Button
double a,b,t;
a=Double.parseDouble(jTextField1.getText());
b=Double.parseDouble(jTextField2.getText());
t=a*b;
jTextField3.setText(""+t);

● Divide Button
double a,b,t;
a=Double.parseDouble(jTextField1.getText());
b=Double.parseDouble(jTextField2.getText());
t=a/b;
jTextField3.setText(""+t);

Commission Calculator
Coding of Project

● Calculate Commission Button


String txt=SalesTF.getText();
double sales, comm;
sales=Double.parseDouble(txt);
//calculate commission
if(sales>30000)
comm=sales*0.15;

else
if(sales>12000)
comm=sales*0.03;
else
comm=0;
//display output
CommLabel.setText("The Commission is Rs "+comm );
Digit to Word
Coding of Project
● Go Button
int num=Integer.parseInt(DigTF.getText());
switch(num){
case 0 :WordLabel.setText("You entered ZERO");
break;
case 1 :WordLabel.setText("You entered ONE");
break;
case 2 :WordLabel.setText("You entered TWO");
break;
case 3 :WordLabel.setText("You entered THREE");
break;
case 4 :WordLabel.setText("You entered FOUR");
break;
case 5 :WordLabel.setText("You entered FIVE");
break;
case 6 :WordLabel.setText("You entered SIX");
break;
case 7 :WordLabel.setText("You entered SEVEN");
break;
case 8 :WordLabel.setText("You entered EIGHT");
break;
case 9 :WordLabel.setText("You entered NINE");
break;
default:WordLabel.setText("Please enter digit in the range 0...9");
break;

Discount Calculator
Coding of Project
● Calculate button
double amt = Double.parseDouble(AmtTF.getText());
double disc, discount, discamt;
//Calculate Discount
if (amt > 1000)
disc = 10;
else
disc = 0;
discount = amt*disc/100;
discamt = amt - discount;
//Display Result
Per.setText("Discount="+disc+"%");
Ted.setText(""+discamt);
● Clean Button
Per.setText(""+"");
Ted.setText(""+"");
AmtTF.setText(""+"");
Percentage to Grade
Coding of Project
● Calculate Final Grade Button
int score = Integer.parseInt(txtNum.getText());
String grade;
if(score>=90 && score<=100)
grade ="A++";
else if(score>=80 && score<90)
grade="A+";
else if(score>=75 && score<80)
grade="A";
else if(score>=60 && score<75)
grade="B";
else if(score>=50 && score<60)
grade="C";
else if(score>=40 && score<50)
grade="D";
else if(score>=0 && score<40)
grade="Fail";
else
grade="Invalid Percentage";
lblRes.setText(""+grade);

Rate of Interest Calculator


Coding of Project
● Calculate Button
double prin;
int time;
prin=Double.parseDouble(PrinTF.getText());
time=Integer.parseInt(TimeTF.getText());
double rate;
if(prin<25000)
rate=6.0;
else{
switch(time){
case 7:rate=7.0;
break;
case 10:rate=8.5;
break;
case 15:rate=9.5;
break;
case 20:rate=12.0;
break;
default:rate=6.75;
break;
}
}
RatePercLabel.setText(""+rate+"%");
double tamt=prin*Math.pow((1+rate/100),time);
TotalAmountLabel.setText("Final amaount payable will be Rs "+tamt);

Ticket Booking System


Coding of Project
● Book Seats Now Button
String txt=SeatsTF.getText();
int num=Integer.parseInt(txt);
int lastnum=Integer.parseInt(LastSeatNoLabel.getText());
String lastrow=LastSeatRowLabel.getText();
SeatsNosLabel.setText("");
if(lastrow.compareTo("-")==0)
lastrow = "1";
int x,seatrow;
for(x=0;x>num;++x) {
lastnum++;
if(lastnum>26) {
if(lastrow.compareTo("9")==0) {
String text1=SeatsNosLabel.getText();
SeatsNosLabel.setText(text1+"House Full!");
break;
}
else{
lastnum=1;
seatrow=Integer.parseInt(lastrow)+1;
lastrow=(""+seatrow);
}
}
String text1=SeatsNosLabel.getText();
if (lastnum<=9) {
SeatsNosLabel.setText(text1+lastrow+"0"+lastnum+",");
}
else
SeatsNosLabel.setText(text1+lastrow+lastnum+",");
LastSeatRowLabel.setText(lastrow);
LastSeatNoLabel.setText(""+lastnum);
}

You might also like