Meaningless Drivel is fun!*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What Watch "What New topic
Author

What's wrong???

Ke rem
Greenhorn

Joined: Apr 12, 2006
Posts: 5
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

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


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


pascal
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
Greenhorn

Joined: Apr 12, 2006
Posts: 5
Dont worry Idid it. It's OK. thanks...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: What's wrong???
 
Similar Threads
Help with english to morse code program, I have no idea what I'm doing
Stack Problem
Trouble with system.in manipulation
Need help with algorithm
read int inputs