Canteen food order ,generate total bill using java swing | Gui application, mini Project , java


Canteen food order ,generate total bill using java swing | Gui application, mini Project

 
 
 
Here you can select food categories and number of item  then after order you can generate total bill 
////

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import java.io.*;
public class CanteenT implements ActionListener

JFrame f;
JTabbedPane tb;
CanteenT()
{
f=new JFrame(“Canteen”);
tb=new JTabbedPane();
f.setVisible(true);
f.setSize(1500,1500);
tb.addTab(“Veg”,new Veg());
tb.addTab(“Nonveg”,new Nonveg());
tb.addTab(“Bill”,new Bill());
f.add(tb);
}
public void actionPerformed(ActionEvent ae)
{
}
public static void main(String…aa)
{
new CanteenT();
}
}



class Veg extends JPanel implements ActionListener
{
JButton b1;
JLabel l1,l2,l3,l4;
JTextField t1,t2;
Veg()
{
b1=new JButton(“Bill”);
l1=new JLabel(“Idli:25 “);
l2=new JLabel(“Dosa:30”);
l3=new JLabel(“Enter quantity”);
l4=new JLabel(“Enter quantity”);
t1=new JTextField(10);
t2=new JTextField(10);
add(l1);
add(l3);
add(t1);
add(l2);
add(l4);
add(t2);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource().equals(b1))
{int c;
int a=Integer.parseInt(t1.getText());
int b=Integer.parseInt(t2.getText());
c=(a*25)+(b*30);
String h=String.valueOf(c);
try
{
FileWriter x=new FileWriter(“bill1.txt”);
{
x.write(h);
x.close();
}
}
catch(IOException jj)
{}
}
}
}


class Nonveg extends JPanel implements ActionListener
{
JButton b1;
JLabel l1,l2,l3,l4;
JTextField t1,t2;
Nonveg()
{
b1=new JButton(“Bill”);
l1=new JLabel(“Chicken:150 “);
l2=new JLabel(“Mutton:430”);
l3=new JLabel(“Enter quantity”);
l4=new JLabel(“Enter quantity”);
t1=new JTextField(10);
t2=new JTextField(10);
add(l1);
add(l3);
add(t1);
add(l2);
add(l4);
add(t2);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource().equals(b1))
{int c1;
int a1=Integer.parseInt(t1.getText());
int b1=Integer.parseInt(t2.getText());
c1=(a1*150)+(b1*430);
String h1=String.valueOf(c1);
try
{
FileWriter y=new FileWriter(“bill2.txt”);
{
y.write(h1);
y.close();
}
}
catch(IOException jj)
{}
}
}
}
class Bill extends JPanel implements ActionListener
{
JLabel l1;
JTextField t1;
JButton b1;
Bill()
{
l1=new JLabel(“Your bill is”);
t1=new JTextField(10);
b1=new JButton(“Bill”);
add(l1);
add(t1);
add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource().equals(b1))
{try
{
InputStream is=new FileInputStream(“bill1.txt”);
BufferedReader buf=new BufferedReader(new InputStreamReader(is));
String hjk=buf.readLine();
int kk=Integer.parseInt(hjk);
InputStream is1=new FileInputStream(“bill2.txt”);
BufferedReader buf1=new BufferedReader(new InputStreamReader(is1));
String k=buf1.readLine();
int jk=Integer.parseInt(k);
int f=kk+jk;
t1.setText(String.valueOf(f));
}
catch(Exception fd)
{}
}
}
}

For more Project

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.