package lord1;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import javax.swing.JButton;
import javax.swing.event.CaretListener;
import javax.swing.event.CaretEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;
public class caculate extends JFrame {
private JPanel contentPane;
private JTextField tfNumforCH;
private JTextField tfNumforT;
private JTextField tfNumforA;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {caculate frame = new caculate();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public caculate() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblWelcomeToPeoples = new JLabel("Welcome to Peoples Park Davao");
lblWelcomeToPeoples.setFont(new Font("Times New Roman", Font.BOLD, 20));
lblWelcomeToPeoples.setBounds(85, 11, 282, 25);
contentPane.add(lblWelcomeToPeoples);
JLabel lblEntranceFeeFor = new JLabel("Entrance fee for");
lblEntranceFeeFor.setBounds(108, 48, 109, 25);
contentPane.add(lblEntranceFeeFor);
JLabel lblChildrenBelow = new JLabel("Children below 8");
lblChildrenBelow.setBounds(108, 84, 98, 14);
contentPane.add(lblChildrenBelow);
JLabel lblNewLabel = new JLabel("Tennager 17 below");
lblNewLabel.setBounds(108, 109, 109, 14);
contentPane.add(lblNewLabel);
JLabel lblAdult = new JLabel("Adult");
lblAdult.setBounds(108, 134, 81, 14);
contentPane.add(lblAdult);
JLabel lblFees = new JLabel("Fees");
lblFees.setBounds(269, 52, 46, 14);
contentPane.add(lblFees);
JLabel lblphp = new JLabel("5 php");
lblphp.setBounds(269, 84, 46, 14);
contentPane.add(lblphp);
JLabel lblphp_1 = new JLabel("7 php");
lblphp_1.setBounds(269, 109, 46, 14);
contentPane.add(lblphp_1);
JLabel lblphp_2 = new JLabel("10 php");
lblphp_2.setBounds(269, 134, 46, 14);
contentPane.add(lblphp_2);
JLabel lblNewLabel_1 = new JLabel("Payment Here:");
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 11));
lblNewLabel_1.setBounds(10, 160, 98, 14);
contentPane.add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("Children");
lblNewLabel_2.setBounds(108, 175, 45, 15);
contentPane.add(lblNewLabel_2);
JLabel lblTeenager = new JLabel("Teenager");
lblTeenager.setBounds(108, 195, 81, 15);
contentPane.add(lblTeenager);
JLabel label_1 = new JLabel("Children");
label_1.setBounds(108, 215, 45, 15);
contentPane.add(label_1);
tfNumforCH = new JTextField();
tfNumforCH.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent arg0) {
int num1 = Integer.parseInt(tfNumforCH.getText());
int total = num1 * 5;
textField.setText(""+total);
textField_3.setText(""+total);
}
});
tfNumforCH.setBounds(270, 175, 35, 15);
contentPane.add(tfNumforCH);
tfNumforCH.setColumns(10);
tfNumforT = new JTextField();
tfNumforT.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
int num1 = Integer.parseInt(tfNumforT.getText());
int num2 = Integer.parseInt(tfNumforCH.getText());
int total = num1 * 7;
textField_1.setText(""+total);
int total1 = total + num2;
textField_3.setText(""+total1);
}
});
tfNumforT.setColumns(10);
tfNumforT.setBounds(270, 195, 35, 15);
contentPane.add(tfNumforT);
tfNumforA = new JTextField();
tfNumforA.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
int num1 = Integer.parseInt(tfNumforA.getText());
int total = num1 * 10;
textField_2.setText(""+total);
int num01 = Integer.parseInt(textField.getText());
int num02 = Integer.parseInt(textField_1.getText());
int num03 = Integer.parseInt(textField_2.getText());
int total1 = num01 + num02 + num03;
textField_3.setText(""+total1);
}
});
tfNumforA.setColumns(10);
tfNumforA.setBounds(269, 215, 35, 15);
contentPane.add(tfNumforA);
JSeparator separator = new JSeparator();
separator.setBounds(345, 233, 50, 2);
contentPane.add(separator);
JLabel lblNewLabel_3 = new JLabel("Total");
lblNewLabel_3.setBounds(310, 237, 46, 14);
contentPane.add(lblNewLabel_3);
textField = new JTextField();
textField.setEditable(false);
textField.setEnabled(false);
textField.setColumns(10);
textField.setBounds(349, 175, 35, 15);
contentPane.add(textField);
textField_1 = new JTextField();
textField_1.setEnabled(false);
textField_1.setEditable(false);
textField_1.setColumns(10);
textField_1.setBounds(349, 195, 35, 15);
contentPane.add(textField_1);
textField_2 = new JTextField();
textField_2.setEnabled(false);
textField_2.setEditable(false);
textField_2.setColumns(10);
textField_2.setBounds(349, 215, 35, 15);
contentPane.add(textField_2);
textField_3 = new JTextField();
textField_3.setEnabled(false);
textField_3.setEditable(false);
textField_3.setColumns(10);
textField_3.setBounds(350, 236, 35, 15);
contentPane.add(textField_3);
JButton submit = new JButton("Submit");
submit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JOptionPane.showMessageDialog(null, "OK");
}
});
submit.setBounds(230, 235, 75, 21);
contentPane.add(submit);
}
}
Friday, September 27, 2013
Exercise no. 27
package lord1;
import java.util.Arrays;
import javax.swing.JOptionPane;
public class sort {
public static void main(String[] args) {
String [] names = {"Lord","Welhim","Mitch","Lucker"};
String output = "";
Arrays.sort(names);
for ( String name: names ){
output = output+"\n"+name;
}
JOptionPane.showMessageDialog(null, output);
}
}
import java.util.Arrays;
import javax.swing.JOptionPane;
public class sort {
public static void main(String[] args) {
String [] names = {"Lord","Welhim","Mitch","Lucker"};
String output = "";
Arrays.sort(names);
for ( String name: names ){
output = output+"\n"+name;
}
JOptionPane.showMessageDialog(null, output);
}
}
Exercise no. 24
package lord1;
import java.util.Arrays;
import javax.swing.JOptionPane;
public class elementarray {
public static void main(String[] args) {
int [] num = {11,200,32,44,5,10,15,20,60};
String output = "";
Arrays.sort(num);
for ( int x: num ){
output = output+"\n"+x;
}
JOptionPane.showMessageDialog(null, output);
}
}
import java.util.Arrays;
import javax.swing.JOptionPane;
public class elementarray {
public static void main(String[] args) {
int [] num = {11,200,32,44,5,10,15,20,60};
String output = "";
Arrays.sort(num);
for ( int x: num ){
output = output+"\n"+x;
}
JOptionPane.showMessageDialog(null, output);
}
}
Thursday, September 26, 2013
Exercise no. 40
package lord1;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class positivenegativeoe extends JFrame implements ActionListener
{
private Container con=getContentPane();
JButton ok;
JLabel number;
JTextField fieldnumber;
JPanel one,two,main;
public void actionPerformed(ActionEvent e)
{
try{
Double x=(double) 0;
if(e.getSource().equals(ok))
{
x=Double.parseDouble(fieldnumber.getText());
if(x>0)
{
//positive
if(x%2==0)
{
JOptionPane.showMessageDialog(main," EVEN-POSITIVE");
fieldnumber.setText("");
}
else
{
JOptionPane.showMessageDialog(main," ODD-POSITIVE");
fieldnumber.setText("");
}
}
else
{
//negative
if(x%2==0)
{
JOptionPane.showMessageDialog(main," EVEN-NEGATIVE");
fieldnumber.setText("");
}
else
{
JOptionPane.showMessageDialog(main," ODD-NEGATIVE");
fieldnumber.setText("");
}
}
}
}catch(Exception f)
{
JOptionPane.showMessageDialog(main,"Please try again");
fieldnumber.setText("");
}
}
public positivenegativeoe()
{
ok=new JButton("OK");
ok.setBackground(Color.gray);
ok.setForeground(Color.WHITE);
number=new JLabel("Enter number :");
fieldnumber=new JTextField(10);
ok.addActionListener(this);
one=new JPanel(new GridLayout(1,2));
one.add(number);
two=new JPanel(new GridLayout(1,2));
two.add(fieldnumber);
two.add(ok);
main=new JPanel(new GridLayout(2,1));
main.add(one);
main.add(two);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.add(main);
setSize(300,150);
setVisible(true);
}
public static void main(String[]args)
{
positivenegativeoe out=new positivenegativeoe();
out.setLocationRelativeTo(null);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class positivenegativeoe extends JFrame implements ActionListener
{
private Container con=getContentPane();
JButton ok;
JLabel number;
JTextField fieldnumber;
JPanel one,two,main;
public void actionPerformed(ActionEvent e)
{
try{
Double x=(double) 0;
if(e.getSource().equals(ok))
{
x=Double.parseDouble(fieldnumber.getText());
if(x>0)
{
//positive
if(x%2==0)
{
JOptionPane.showMessageDialog(main," EVEN-POSITIVE");
fieldnumber.setText("");
}
else
{
JOptionPane.showMessageDialog(main," ODD-POSITIVE");
fieldnumber.setText("");
}
}
else
{
//negative
if(x%2==0)
{
JOptionPane.showMessageDialog(main," EVEN-NEGATIVE");
fieldnumber.setText("");
}
else
{
JOptionPane.showMessageDialog(main," ODD-NEGATIVE");
fieldnumber.setText("");
}
}
}
}catch(Exception f)
{
JOptionPane.showMessageDialog(main,"Please try again");
fieldnumber.setText("");
}
}
public positivenegativeoe()
{
ok=new JButton("OK");
ok.setBackground(Color.gray);
ok.setForeground(Color.WHITE);
number=new JLabel("Enter number :");
fieldnumber=new JTextField(10);
ok.addActionListener(this);
one=new JPanel(new GridLayout(1,2));
one.add(number);
two=new JPanel(new GridLayout(1,2));
two.add(fieldnumber);
two.add(ok);
main=new JPanel(new GridLayout(2,1));
main.add(one);
main.add(two);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.add(main);
setSize(300,150);
setVisible(true);
}
public static void main(String[]args)
{
positivenegativeoe out=new positivenegativeoe();
out.setLocationRelativeTo(null);
}
}
Exercise no. 39
package lord1;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.ActionListener;
public class d5 extends JFrame implements ActionListener
{
private Container con=getContentPane();
JLabel first ;
JButton ok,cancel;
JTextField firstnum,secondnum,result;
JPanel firstpanel,secondpanel,mainpanel1,mainpanel;
JPanel field1,field2,results;
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(ok))
{
String textFieldValue1="";
String divisible="";
String textFieldValue2="";
Integer result2=0;
if(firstnum.getText().equals("") || secondnum.getText().equals(""))
{
{
}
JOptionPane.showMessageDialog(firstpanel, "Please try again");
firstnum.setText("");
secondnum.setText("");
}
else
{
try{
textFieldValue1=firstnum.getText();
textFieldValue2 = secondnum.getText();
int x=Integer.parseInt(textFieldValue1);
int y=Integer.parseInt(textFieldValue2);
result2=x+y;
if(result2 % 5==0)
{
divisible="and is divisible by 5.";
}
else
{
divisible="and is not divisible by 5.";
}
result.setText("The sum is : "+result2+"\t"+divisible);
}
catch (Exception f)
{
JOptionPane.showMessageDialog(firstpanel, "Please use number");
firstnum.setText("");
secondnum.setText("");
}
}
}
else if(e.getSource().equals(cancel))
{
firstnum.setText("");
secondnum.setText("");
result.setText("");
}
}
public d5()
{
first=new JLabel("Enter first number :");
ok=new JButton("OK");
ok.setBackground(Color.gray);
ok.setForeground(Color.WHITE);
cancel=new JButton("CANCEL");
cancel.setBackground(Color.gray);
cancel.setForeground(Color.WHITE);
firstnum=new JTextField(10);
secondnum=new JTextField(10);
result=new JTextField(20);
result.setEditable(false);
secondpanel=new JPanel(new GridLayout(1,2));
ok.addActionListener(this);
cancel.addActionListener(this);
secondpanel.add(ok);
secondpanel.add(cancel);
Border border = BorderFactory.createLineBorder(Color.orange, 5);
firstnum.setBorder(border);
secondnum.setBorder(border);
firstpanel=new JPanel(new GridLayout(3,1));
firstpanel.add(first);
firstpanel.add(firstnum);
firstpanel.add(secondnum);
results=new JPanel();
mainpanel1=new JPanel(new GridLayout(2,1));
mainpanel1.add(firstpanel);
mainpanel1.add(secondpanel);
mainpanel=new JPanel(new GridLayout(1,2));
mainpanel.add(mainpanel1);
mainpanel.setBackground(Color.GREEN);
con.setLayout(new GridLayout(1,2));
con.add(mainpanel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.setLayout(new FlowLayout());
con.add(results);
results.add(result);
results.setBackground(Color.orange);
setSize(500, 200);
setVisible(true);
}
public static void main(String[]args)
{
d5 d =new d5();
}
}
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.ActionListener;
public class d5 extends JFrame implements ActionListener
{
private Container con=getContentPane();
JLabel first ;
JButton ok,cancel;
JTextField firstnum,secondnum,result;
JPanel firstpanel,secondpanel,mainpanel1,mainpanel;
JPanel field1,field2,results;
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(ok))
{
String textFieldValue1="";
String divisible="";
String textFieldValue2="";
Integer result2=0;
if(firstnum.getText().equals("") || secondnum.getText().equals(""))
{
{
}
JOptionPane.showMessageDialog(firstpanel, "Please try again");
firstnum.setText("");
secondnum.setText("");
}
else
{
try{
textFieldValue1=firstnum.getText();
textFieldValue2 = secondnum.getText();
int x=Integer.parseInt(textFieldValue1);
int y=Integer.parseInt(textFieldValue2);
result2=x+y;
if(result2 % 5==0)
{
divisible="and is divisible by 5.";
}
else
{
divisible="and is not divisible by 5.";
}
result.setText("The sum is : "+result2+"\t"+divisible);
}
catch (Exception f)
{
JOptionPane.showMessageDialog(firstpanel, "Please use number");
firstnum.setText("");
secondnum.setText("");
}
}
}
else if(e.getSource().equals(cancel))
{
firstnum.setText("");
secondnum.setText("");
result.setText("");
}
}
public d5()
{
first=new JLabel("Enter first number :");
ok=new JButton("OK");
ok.setBackground(Color.gray);
ok.setForeground(Color.WHITE);
cancel=new JButton("CANCEL");
cancel.setBackground(Color.gray);
cancel.setForeground(Color.WHITE);
firstnum=new JTextField(10);
secondnum=new JTextField(10);
result=new JTextField(20);
result.setEditable(false);
secondpanel=new JPanel(new GridLayout(1,2));
ok.addActionListener(this);
cancel.addActionListener(this);
secondpanel.add(ok);
secondpanel.add(cancel);
Border border = BorderFactory.createLineBorder(Color.orange, 5);
firstnum.setBorder(border);
secondnum.setBorder(border);
firstpanel=new JPanel(new GridLayout(3,1));
firstpanel.add(first);
firstpanel.add(firstnum);
firstpanel.add(secondnum);
results=new JPanel();
mainpanel1=new JPanel(new GridLayout(2,1));
mainpanel1.add(firstpanel);
mainpanel1.add(secondpanel);
mainpanel=new JPanel(new GridLayout(1,2));
mainpanel.add(mainpanel1);
mainpanel.setBackground(Color.GREEN);
con.setLayout(new GridLayout(1,2));
con.add(mainpanel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.setLayout(new FlowLayout());
con.add(results);
results.add(result);
results.setBackground(Color.orange);
setSize(500, 200);
setVisible(true);
}
public static void main(String[]args)
{
d5 d =new d5();
}
}
Exercise no. 38
package lord1;
import javax.swing.*;
import java.awt.*;
public class guiframe extends JFrame
{
private static final Color yellowgreen = null;
private Container con=getContentPane();
final int width_of_Frame=400;
final int height_of_Frame=150;
JLabel first=new JLabel (" Enter first number :");
JLabel second=new JLabel("Enter second number :");
JTextField firstfield=new JTextField(10);
JTextField secondfield=new JTextField(10);
JButton ok = new JButton (" 1OK" );
JButton Cancel = new JButton("Cancel");
public guiframe()
{
super("My JFrame");
setSize(width_of_Frame,height_of_Frame);
JPanel firstfieldpane =new JPanel();
JPanel secondfieldpane =new JPanel();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.setLayout(new FlowLayout());
con.add(first);
con.add(firstfieldpane);
con.add(ok);
con.add(second);
con.add(secondfieldpane);
con.add(Cancel);
ok.setBackground(Color.green);
Cancel.setBackground(Color.green);
firstfieldpane.add(firstfield);
firstfieldpane.setBackground(Color.orange);
secondfieldpane.add(secondfield);
secondfieldpane.setBackground(Color.orange);
}
public static void main(String[]args)
{
guiframe myframe=new guiframe();
myframe.setVisible(true);
}
}
import javax.swing.*;
import java.awt.*;
public class guiframe extends JFrame
{
private static final Color yellowgreen = null;
private Container con=getContentPane();
final int width_of_Frame=400;
final int height_of_Frame=150;
JLabel first=new JLabel (" Enter first number :");
JLabel second=new JLabel("Enter second number :");
JTextField firstfield=new JTextField(10);
JTextField secondfield=new JTextField(10);
JButton ok = new JButton (" 1OK" );
JButton Cancel = new JButton("Cancel");
public guiframe()
{
super("My JFrame");
setSize(width_of_Frame,height_of_Frame);
JPanel firstfieldpane =new JPanel();
JPanel secondfieldpane =new JPanel();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.setBackground(Color.green);
con.setLayout(new FlowLayout());
con.add(first);
con.add(firstfieldpane);
con.add(ok);
con.add(second);
con.add(secondfieldpane);
con.add(Cancel);
ok.setBackground(Color.green);
Cancel.setBackground(Color.green);
firstfieldpane.add(firstfield);
firstfieldpane.setBackground(Color.orange);
secondfieldpane.add(secondfield);
secondfieldpane.setBackground(Color.orange);
}
public static void main(String[]args)
{
guiframe myframe=new guiframe();
myframe.setVisible(true);
}
}
Exercise no. 28
package lord1;
import javax.swing.JOptionPane;
public class mmultiplication {
public static void main(String[]args)
{
Integer []ratepeproduct=new Integer[3];
Integer [][]item_order_perday=new Integer[3][4];
Integer []result=new Integer[4];
Integer beef=0,chicken=0,vegetable=0;
Integer orderitem=0,datecurrent=0,beef2=0,chicken2=0,vegetable2=0;
String day[]=new String []{"Monday","Tuesday","Wednesday","Thursday"};
int sum=0;
for(int y=0;y<3;y++)
{
if( y==0)
{
beef=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Price for Beef"));
ratepeproduct[y]=beef;
}
if( y==1)
{
chicken=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Price for chicken"));
ratepeproduct[y]=chicken;
}
if( y==2)
{
vegetable=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Price for vegetable"));
ratepeproduct[y]=vegetable;
}
}
for(int xx=0;xx<3;xx++)
{
for(int yy=0;yy<4;yy++)
{
orderitem=Integer.parseInt(JOptionPane.showInputDialog(null,day[yy] ));
item_order_perday[xx][yy]=orderitem;
orderitem=0;
}
}
for ( int d = 0 ; d < 4 ; d++ )
{
for ( int k = 0 ; k < 3 ; k++ )
{
if(k==0)
{
beef2 = beef2 + ratepeproduct[k]*item_order_perday[k][d];
}
if(k==1)
{
chicken2 = chicken2 + ratepeproduct[k]*item_order_perday[k][d];
}
if(k==2)
{
vegetable2 = vegetable2 + ratepeproduct[k]*item_order_perday[k][d];
}
sum = sum + ratepeproduct[k]*item_order_perday[k][d];
}
result[d] = sum;
sum = 0;
}
for (int d = 0 ; d < 4 ; d++ )
{
JOptionPane.showMessageDialog(null,day[d]+" Income : "+result[d]);
}
JOptionPane.showMessageDialog(null,"Total Income in beef from monday to thursday is : P" +beef2);
JOptionPane.showMessageDialog(null,"Total Income in chicken from monday to thursday is : P" +chicken2);
JOptionPane.showMessageDialog(null,"Total Income in vegetable from monday to thursday is : P" +vegetable2);
}
}
import javax.swing.JOptionPane;
public class mmultiplication {
public static void main(String[]args)
{
Integer []ratepeproduct=new Integer[3];
Integer [][]item_order_perday=new Integer[3][4];
Integer []result=new Integer[4];
Integer beef=0,chicken=0,vegetable=0;
Integer orderitem=0,datecurrent=0,beef2=0,chicken2=0,vegetable2=0;
String day[]=new String []{"Monday","Tuesday","Wednesday","Thursday"};
int sum=0;
for(int y=0;y<3;y++)
{
if( y==0)
{
beef=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Price for Beef"));
ratepeproduct[y]=beef;
}
if( y==1)
{
chicken=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Price for chicken"));
ratepeproduct[y]=chicken;
}
if( y==2)
{
vegetable=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Price for vegetable"));
ratepeproduct[y]=vegetable;
}
}
for(int xx=0;xx<3;xx++)
{
for(int yy=0;yy<4;yy++)
{
orderitem=Integer.parseInt(JOptionPane.showInputDialog(null,day[yy] ));
item_order_perday[xx][yy]=orderitem;
orderitem=0;
}
}
for ( int d = 0 ; d < 4 ; d++ )
{
for ( int k = 0 ; k < 3 ; k++ )
{
if(k==0)
{
beef2 = beef2 + ratepeproduct[k]*item_order_perday[k][d];
}
if(k==1)
{
chicken2 = chicken2 + ratepeproduct[k]*item_order_perday[k][d];
}
if(k==2)
{
vegetable2 = vegetable2 + ratepeproduct[k]*item_order_perday[k][d];
}
sum = sum + ratepeproduct[k]*item_order_perday[k][d];
}
result[d] = sum;
sum = 0;
}
for (int d = 0 ; d < 4 ; d++ )
{
JOptionPane.showMessageDialog(null,day[d]+" Income : "+result[d]);
}
JOptionPane.showMessageDialog(null,"Total Income in beef from monday to thursday is : P" +beef2);
JOptionPane.showMessageDialog(null,"Total Income in chicken from monday to thursday is : P" +chicken2);
JOptionPane.showMessageDialog(null,"Total Income in vegetable from monday to thursday is : P" +vegetable2);
}
}
Subscribe to:
Posts (Atom)