Home » » Switch with input in Java Program

Switch with input in Java Program

Switch with input in Java Program

Switch with input in Java Program


Switch with input in Java Program

import java.io.*;
class arun
{
public Static void main(String args[]) throws IOException
{
DataInputStream in = new DataInputStream(System.in);
{
int a;
System.out.println("Enter the value of a is:");
a=Integer.parseInt(in.readLine());
switch(a)
{
case 1:
{
int b,c,d;
System.out.println("Enter the value of b and c is:");
b=Integer.parseInt(in.readLine());
c=Integer.parseInt(in.readLine());
d=b+c;
System.out.println("The value of d is:"+d);
break;
}
case 2:
{
int b,c,d;
System.out.println("The enter value of b and c is:");
b=Integer.parseInt(in.readLine());
c=Integer.parseInt(in.readLine());
d=b-c;
System.out.println("The value of d is:"+d);
break;
}
case 3:
{
int b,c,d;
System.out.println("Enter the value of b and c is:");
b=Integer.parseInt(in.readLine());
c=Integer.parseInt(in.readLine());
d=b*c;
break;
System.out.println("The value of d is:"+d);
}
case 4:
{
int b,c,d;
System.out.println("Enter the value of b and c is");
b=Integer.parseInt(in.readLine());
c=Integer.parseInt(in.readLine());
d=b/c;
break;
System.out.println("The value of d is:"+d);
}
default:
{
System.out.println("You entered the wrong number");
break;
}
}
}
}
}

0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g