Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!

# What's wrong???

Ke rem
Greenhorn
Posts: 5
import java.io.* ;

public class Avaragerr {
public static void main(String args[]) throws IOException {
System.out.println("Birinci Sayiyi girin(x)");
System.out.println("Ikinci Sayiyi girin(y)");
int x = Integer.parseInt(oku);
int y = Integer.parseInt(oku2);

do {
System.out.println("1.Toplama\n2.Cikarma\n3.Carpma\n4.Bolme");

switch(int z) {
case 1: Topla(x,y); break;
case 2: Cikar(x,y); break;
case 3: Carp(x,y); break;
case 4: Bol(x,y); break;
default:
System.out.println("Yanlis Secim!");
}
} while(z>0&&z<5);

}
public static double Topla(int x, int y) {
return (x+y);
}
public static double Cikar(int x, int y) {
return (x-y);
}
public static double Carp(int x, int y) {
return (x*y);
}
public static double Bol(int x, int y) {
return(x/y);
}

}

pascal betz
Ranch Hand
Posts: 547
yes, whats wrong ?

please give an explanation whats goign wrong, exceptions, comppiler errors or whatsoever....

pascal

Keith Lynn
Ranch Hand
Posts: 2409
Since you didn't tell us what you need help with, there are a couple of problems I notice in your program.

The argument to the switch statement does not include a type.

Also since you never change z, then the loop won't stop.

Also in the method where you divide the parameters, an int divided by an int is an int. It doesn't matter if the return type is a double, the division won't be double.

Ke rem
Greenhorn
Posts: 5
Dont worry Idid it. It's OK. thanks...