Thursday, September 26, 2013

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);

}
  
       
    }

No comments:

Post a Comment