Hi,
I started with the following code:
class Vereinfache2_edit {
public static void main(String[] args) {
int c1 = Integer.parseInt(args[0]);
int c2 = Integer.parseInt(args[1]);
int c3 = Integer.parseInt(args[2]);
/* 1 */if (c2 - c1 == 0) {
/* 2 */if (c1 != c3) {
c3 += c1;
/* 4 */System.out.println(c3);
/* 5 */c3 *= c2;
/* 6 */}
}
/* 7 */if (c1 == c3)
/* 8 */if (c1 - c2 == 0)
/* 9 */{
c3 += c1;
/* 10 */System.out.println(c3);
/* 11 */c3 *= c1;
/* 12 */if (c1 < c2)
c2 += 7;
/* 13 */else
c2 += 5;
/* 14 */}
/* 15 */System.out.println(c1 + c2 + c3);
}
} // end of class Vereinfache2
...and I ended with:
class Vereinfache2 {
public static void main(String [] args) {
int c1 = Integer.parseInt(args[0]) ;
int c2 = Integer.parseInt(args[1]) ;
int c3 = Integer.parseInt(args[2]) ;
/* 1 */
/* 2 */ if (c2 == c1 && c1 != c3){
/* 4 */ System.out.println(c3 += c2) ;
/* 5 */ c3 = c3 * c2 ;
/* 6 */ }
/* 7 */
/* 8 */ if ( c2 == c1 && c1 == c3){
/* 10 */ System.out.println(c3 *= 2) ;
/* 11 */ c3 = c3 * c2 ; c2 = c2 + 5 ;
/* 14 */ }
/* 15 */ System.out.println( c1+c2+c3) ;
}
} // end of class Vereinfache2
Do you see anything else like dead or switchable code?
Thanks for all answers. I ended up with this working version:
class Vereinfache2 {
public static void main(String [] args) {
int c1 = Integer.parseInt(args[0]) ;
int c2 = Integer.parseInt(args[1]) ;
int c3 = Integer.parseInt(args[2]) ;
/* 1 */ if(c2 == c1){
/* 2 */ if (c1 != c3){
c3 += c2;
/* 4 */ System.out.println(c3) ;
/* 6 */ }else{
c3 *= 2;
/* 10 */ System.out.println(c3) ;
/* 14 */ }
c3 *= c2; c2 += 5;
}
/* 15 */ System.out.println(c1+c2+c3) ;
}
} // end of class Vereinfache2