Sunteți pe pagina 1din 3

import java.util.

Date;

public class ordring extends javax.swing.JFrame {

Double price1=12.50;
Double price2=18.50;
Double price3=20.40;
String productname1, mode,productname2,productname3;

private void radiocreditcardActionPerformed(java.awt.event.ActionEvent evt) {


if(radiocreditcard.isSelected())
mode="CASH";
radiocash.setSelected(false);
}

private void chkorder1ActionPerformed(java.awt.event.ActionEvent evt) {

if(chkorder1.isSelected())
Jtxtqty1.setEnabled(true);
productname1 ="SPAGGETI";

private void chkorder2ActionPerformed(java.awt.event.ActionEvent evt) {


if(chkorder2.isSelected())
Jtxtqty2.setEnabled(true);
productname2 ="PANCIT";
}

private void chkorder3ActionPerformed(java.awt.event.ActionEvent evt) {


if(chkorder3.isSelected())
Jtxtqty3.setEnabled(true);
productname3 ="BIHON";
}

private void btncomputeActionPerformed(java.awt.event.ActionEvent evt) {


double qty1= Double.parseDouble(Jtxtqty1.getText());
double qty2= Double.parseDouble(Jtxtqty2.getText());
double qty3= Double.parseDouble(Jtxtqty3.getText());

double taxrate=.12;

String purchase1=String.valueOf(price1*qty1);
subtotal1.setText(purchase1);
String purchase2=String.valueOf(price2*qty2);
subtotal2.setText(purchase2);
String purchase3=String.valueOf(price3*qty3);
subtotal3.setText(purchase3);

double purchase1a=Double.parseDouble(subtotal1.getText());
double purchase2a=Double.parseDouble(subtotal2.getText());
double purchase3a=Double.parseDouble(subtotal3.getText());

String Subtotalall=String.valueOf(purchase1a+purchase2a+purchase3a);
txtordertotal.setText(Subtotalall);

double SubtotalallA=Double.parseDouble(txtordertotal.getText());

String Tax=String.valueOf(SubtotalallA*taxrate);
txttax.setText(Tax);

double total=Double.parseDouble(txtordertotal.getText());
double tax1=Double.parseDouble(txttax.getText());

String NetAmount=String.valueOf(total-tax1);
txtnetamount.setText(NetAmount);

private void btnprintActionPerformed(java.awt.event.ActionEvent evt) {

receipt.setText("***************************************\n");
receipt.setText(receipt.getText()+"****** RECEIPT *****\n");
receipt.setText(receipt.getText()+"*********************************\n");
Date obj= new Date();
String date = obj.toString();
receipt.append("\n"+date+"\n");
receipt.append("\n"+"Name:"+jTname.getText());
receipt.append("\n"+"MODE of Payment:"+mode+"\n");
receipt.append("\n"+"\t"+"QTY"+"\t"+"PRICE"+"\t"+"AMOUNT"+"\n");

receipt.append("\n"+productname1+"\t"+Jtxtqty1.getText()+"\t"+jUnitprice1.getText()+"\t"+subtotal
1.getText()+"\n");

receipt.append("\n"+productname2+"\t"+Jtxtqty2.getText()+"\t"+jUnitprice2.getText()+"\t"+subtotal
2.getText()+"\n");

recePipt.append("\n"+productname3+"\t"+Jtxtqty3.getText()+"\t"+jUnitprice3.getText()+"\t"+subtota
l3.getText()+"\n");

S-ar putea să vă placă și