JAVA PROGRAM OF FOOD ORDERING SYSTEM

/*JAVA PROGRAM TO FOOD ORDERING SYSTEM----In this program create a menu list in frame  and show list  user choice menu and show total amount of user in a message box*/

PROGRAM CODE---

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;


class FoodOrder extends JFrame implements ActionListener

{

    JLabel l;

    JCheckBox c1,c2,c3,c4,c5,c6,c7,c8;

     JButton b1,b2;


        public FoodOrder()

         {


this.setVisible(true);

this.setSize(300,450);

this.setLocation(100,100);

this.setLayout(null);

this.setResizable(false);


l=new JLabel("FOOD ORDERING SYSTEM");

c1=new JCheckBox("Pizza @ 200");

c2=new JCheckBox("Burger@ 100");

c3=new JCheckBox("samosa @ 20");

c4=new JCheckBox("Coffee @ 100");

c5=new JCheckBox("cold drink @ 80");

c6=new JCheckBox("french fries @ 100");

c7=new JCheckBox("chowmein @ 100");

c8=new JCheckBox("Noodles @ 90");

b1= new JButton("order");

b2=new JButton("cancel");


l.setBounds(100,20,350,40);

c1.setBounds(100,80,150,20);

c2.setBounds(100,110,150,20);

c3.setBounds(100,150,150,20);

c4.setBounds(100,180,150,20);

c5.setBounds(100,210,150,20);

c6.setBounds(100,240,150,20);

c7.setBounds(100,270,150,20);

c8.setBounds(100,300,150,20);

b1.setBounds(60,350,80,40);

b2.setBounds(150,350,80,40);


this.add(l);

        this.add(c1);

this.add(c2);

this.add(c3);

this.add(c4);

this.add(c5);

this.add(c6);

this.add(c7);

this.add(c8);

this.add(b1);

this.add(b2);

b1.addActionListener(this);

  c1.addActionListener(this);

c2.addActionListener(this);

c3.addActionListener(this);

c4.addActionListener(this);

c5.addActionListener(this);

c6.addActionListener(this);

c7.addActionListener(this);

c8.addActionListener(this);

}

  public  void actionPerformed(ActionEvent e)

     {

            Object o =e.getSource();

  float amount=0;

                 String msg ="";

  if(c1.isSelected())

{


amount+=200;

msg+="pizza : @200\n";

if(c2.isSelected())

{


amount+=100;

msg+="burger : @100\n";

if(c3.isSelected())

{


amount+=20;

msg+="samosa : @20\n";

if(c4.isSelected())

{


amount+=100;

msg+="coffee : @100\n";

if(c5.isSelected())

{


amount+=80;

msg+="cold drink: @80\n";

if(c6.isSelected())

{


amount+=100;

msg+="french fries : @100\n";

if(c7.isSelected())

{


amount+=100;

msg+="chowmein : @100\n";

if(c8.isSelected())

{


amount+=90;

msg+="noodles : @90\n";


msg+="----------------- \n";

if(o==b1)

{

JOptionPane.showMessageDialog(this, msg + "your Total amount is " + amount);

}

if(o==b2)

{

   int a = JOptionPane.showConfirmDialog(this,"Are you sure ?");

if(a==JOptionPane.YES_OPTION)

{

       this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

}

   }


public static void main(String a[])

{

                new FoodOrder();

                            

}

}







OUTPUT OF ABOVE PROGRAM---



Comments