Computer Science, asked by chandajha515, 10 months ago

Using switch /case write a program offering the user the option of finding 1) Addition 2) subtraction 3) Multiplication 4) Division​

Answers

Answered by sneharekhi14
4

import java.util.*;

class calculations

{

public static void main (String args[] )

{

Scanner sc=new Scanner (System.in);

int n,a,b;

Sopln("enter the no.s");

a=sc.next Int();

b=sc.next Int();

Sopln ("the menu is ");

Sopln("1 for addition \n2 for subtraction \n3 for multiplication \n4 for division ");

Sopln("Enter your choice ");

n=sc.next Int();

Switch(n)

{

case 1 : int sm;

sm=a+b;

Sopln("the sum is "+ sm );

break;

case 2 : int sb;

sb=a-b;

Sopln("the difference is "+ sb );

break;

case 3 : int m;

m=a*b;

Sopln("the product is "+ m );

break;

case 4 : double d;

d=a/b;

Sopln("the quotient is "+ d );

break;

default : Sopln("wrong choice");

break;

}

}

}

hope it HELPS

plzzzz mark as BRAINLIEST

Similar questions