Oh. It's good. :D I just wrote an explanation of the mistake. Glad that you have found the error. Anyway, I will attach my answer too. Just in case you like to have a look. :) for(x=1;x<5;x++); See that semi colon after then for loop declaration. That tells the compiler that the line has ended. Thus...
I have seen programs Pushing parameters in to the stack before calling a function. (While disassembling little executable files.) . I am taking about x86 assembly.
There is no much about me still. I am 24. Still studying for bachelors. And following another degree course towards an IT degree(currently postponed a bit). At the university, I am following a degree course with Chemistry, Mathematics and Statistics as subjects. And I like IT more than those applied...
Yes. Switch block is the best way to handle this kind of work.
And some exceptions should also be handled. I didn't bother mentioning. He might not know about exceptions yet.
import java.util.Scanner; /** made by gayan bandara. date 07.08.2010 to make a calc*/ public class Gayan_calculator{ static void list(){ System.out.println("1.Add numbers"); System.out.println("2.Substract numbers"); System.out.println("3.Multily numbers"); System.out.println("4.Divide numbers"); }...
Well, when you use "if" there should be a condition to check. The code inside the "if" block will only be evaluated only if the condition of the "if" block is true. I think you are aware of it. Let's see your "if" block. if(selection==+||selection==-||selection==*||selection==\) selection==+ This is...
import java.util.Scanner; /** made by gayan bandara. date 07.08.2010 to make a calc*/ public class Gayan_calculator{ static void list(){ System.out.println("pre+ss + for Add numbers"); System.out.println("press - for Substract numbers"); System.out.println("press * for Multily numbers"); System.out...
with input.nextInt(), the scanner is waiting for a integer value. But you enter an character (char ) . It is the cause for the inputMismatchException. There is no method for reading next character value. But there is a method named "next()". I think you will be able to use that and some casting ( co...