Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's wrong???

 
Ke rem
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.* ;

public class Avaragerr {
public static void main(String args[]) throws IOException {
BufferedReader xx= new BufferedReader(new InputStreamReader(System.in));
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 {
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, whats wrong ?


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


pascal
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont worry Idid it. It's OK. thanks...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic