• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What's wrong???

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}

}

 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, whats wrong ?


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


pascal
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dont worry Idid it. It's OK. thanks...
 
reply
    Bookmark Topic Watch Topic
  • New Topic