pls solve this Blue J question.
Attachments:
Answers
Answered by
2
Here is the answer :-
public class sample
{
public static void main(int a, int b, char n)
{
switch(n)
{
case '+':System.out.print("Addition = "+(a+b));
break;
case'-': System.out.print("Subtraction = "+(a-b));
break;
case'*':System.out.print("Multiplication = "+(a*b));
break;
case'/': System.out.print("Division = "+(a/b));
break;
default: System.out.print("Wrong Input");
}}}
public class sample
{
public static void main(int a, int b, char n)
{
switch(n)
{
case '+':System.out.print("Addition = "+(a+b));
break;
case'-': System.out.print("Subtraction = "+(a-b));
break;
case'*':System.out.print("Multiplication = "+(a*b));
break;
case'/': System.out.print("Division = "+(a/b));
break;
default: System.out.print("Wrong Input");
}}}
manasraj1:
can you please solve this question using if else
{
public static void main(int a, int b, char n)
{
if(n=='+')
System.out.print("Addition = "+(a+b));
else
if(n=='-')
System.out.println("Subtraction = "+(a-b));
else
if(n=='*')
System.out.print("Multiplication = "+(a*b));
else
if(n=='/')
System.out.print("Division = "+(a/b));
}
}}
Similar questions