java if else statement

Posted by user554320 on Stack Overflow See other posts from Stack Overflow or by user554320
Published on 2010-12-26T14:34:50Z Indexed on 2010/12/26 14:54 UTC
Read the original article Hit count: 279

Filed under:

I am a new student who is trying to use java if else statements at the moment.

I have attched my class and i need to say if this code get 0 errors for all 4 errors(error11, error12, error13 and error14), need to display the text "Answer". This code was working without the if else statements and there are 2 errors in those 2 lines. Please explain me how to do it?

public static void deltaR()
 {
 int x;  
 int x11, x12, x13, x14;
 int x21, x22, x23, x24; //inputs

 double w10, w11, w12;//weights for first neuron
 int d11, d12, d13, d14;//desired output for first neuron
 double net11, net12, net13, net14;//sum of weights times inputs
 int y11, y12, y13, y14;//outputs
 int error11, error12, error13, error14;//error

 //double w20, w21, w22;//weights for second neuron
 //int d21, d22, d23, d24;//desired output for second neuron
 //double net21, net22, net23, net24;//sum of weights times input
 //int y21, y22, y23, y24;//outputs
 //int error21, error22, error23, error24;//error

 if (error11 = 0, error12 = 0, error13 = 0, error14 = 0)
 {
  System.out.println("Answer");
 }
 else if (error11 != 0, error12 != 0, error13 != 0, error14 != 0)
 {
 double coe=0.5;//learning coefficient
 x=1;

 x11=0;
 x12=0;
 x13=1;
 x14=1;

 x21=0;
 x22=1;
 x23=0;
 x24=1;

 d11= 0;
 d12= 1;
 d13= 0;
 d14= 1;

 w10=0.5;
 w11=-1;
 w12=1.5;

 net11=(x*w10 + x11*w11 + x21*w12);
 net12=(x*w10 + x12*w11 + x22*w12);
 net13=(x*w10 + x13*w11 + x23*w12);
 net14=(x*w10 + x14*w11 + x24*w12);

 if (net11>=0)
  y11=1;
 else
  y11=0;

 if (net12>=0) 
  y12=1;
 else
  y12=0;

 if (net13>=0)
  y13=1;
 else
  y13=0;

 if (net14>=0) 
  y14=1;
 else
  y14=0;

 error11=(d11-y11);
 error12=(d12-y12);
 error13=(d13-y13);
 error14=(d14-y14);

 System.out.println("net value 1:  "+net11);
 System.out.println("net value 2:  "+net12);
 System.out.println("net value 3:  "+net13);
 System.out.println("net value 4:  "+net14);

 System.out.println("output 1:  "+y11);
 System.out.println("output 2:  "+y12);
 System.out.println("output 3:  "+y13);
 System.out.println("output 4:  "+y14);

 System.out.println("error1:  "+error11);
 System.out.println("error2:  "+error12);
 System.out.println("error3:  "+error13);
 System.out.println("error4:  "+error14);
 }
 }
}

© Stack Overflow or respective owner

Related posts about java