SWITCH CASE IN JAVA
import java.util.*;
class switch1
{
public static void main(String args[])
{
int ch,a,b,c;
Scanner sc=new Scanner(System.in);
System.out.println("1.Addition \n 2.Substraction \n 3.Multiplication\n 4.Division \n5.Modation");
System.out.println("Enter your choice");
ch=sc.nextInt();
System.out.println("Enter the two no");
a=sc.nextInt();
b=sc.nextInt();
switch(ch)
{
case 1:
c=a+b;
System.out.println("Sum="+c);
break;
case 2:
c=a-b;
System.out.println("Sub="+c);
break;
case 3:
c=a*b;
System.out.println("multi="+c);
break;
case 4:
c=a/b;
System.out.println("divis="+c);
break;
case 5:
c=a%b;
System.out.println("modation="+c);
break;
default:
System.out.println("Wrong choice");
break;
}
}
}
class switch1
{
public static void main(String args[])
{
int ch,a,b,c;
Scanner sc=new Scanner(System.in);
System.out.println("1.Addition \n 2.Substraction \n 3.Multiplication\n 4.Division \n5.Modation");
System.out.println("Enter your choice");
ch=sc.nextInt();
System.out.println("Enter the two no");
a=sc.nextInt();
b=sc.nextInt();
switch(ch)
{
case 1:
c=a+b;
System.out.println("Sum="+c);
break;
case 2:
c=a-b;
System.out.println("Sub="+c);
break;
case 3:
c=a*b;
System.out.println("multi="+c);
break;
case 4:
c=a/b;
System.out.println("divis="+c);
break;
case 5:
c=a%b;
System.out.println("modation="+c);
break;
default:
System.out.println("Wrong choice");
break;
}
}
}
Comments
Post a Comment