This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes What's wrong??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What Watch "What New topic

What's wrong???

Ke rem

Joined: Apr 12, 2006
Posts: 5
import* ;

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

do {

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


pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
yes, whats wrong ?

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

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Apr 12, 2006
Posts: 5
Dont worry Idid it. It's OK. thanks...
subject: What's wrong???