Hello
Being a beginner in
java,I am trying to read character input from the console and want to implement switch-case based upon the character input.
I had tried searching this forum and couldn't exactly find a solution.
char c= (char) System.in.read() ,tried this,but it throws an IOexception.
I will greatly appreciate if someboody could guide me for the possible solution.
Thanks
Code:
Want to read character input like +,-,*.. from the console.
//char c = (char)System.in.read();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char c = (char)br.read();
switch(c){
case '+': add(num1,num2);
break;
case '*': multiply(num1,num2);
break;
case '-': subtract(num1,num2);
break;
case '/': divide(num1,num2);
break;