Computer Science, asked by sirchandan, 1 year ago

write a program in Java to input two numbers and the choice if choice is one, print their sum if choice is 2 bring the product, if choice is 3 find the difference if choice is 4 find the average and its no choice display invalid
choice​

Answers

Answered by kill45gmaicom
0

bznsksnsbbs java java

Answered by michaels223
2

Answer:

import java.util.*;

class progA {

void main() {

int choice,a,b;

Scanner sc=new Scannee(System.in);

System.out.println("Enter value of a and b");

a=sc.nextInt();

b=sc.nextInt();

System.out.println("Press 1 for sum");

System.out.println("Press 2 for product");

System.out.println("Press 3 for difference");

System.out.println("Press 4 for average");

System.out.println("Enter your choice");

choice=sc.nextInt();

if(choice==1) {

System.out.println("Sum="+a+b);

}

else if(choice==2) {

System.out.println("Product="+a*b);

}

else if(choice==3) {

System.out.println("Difference="+a-b);

}

else if(choice==4) {

System.out.println("Average="+(a+b)/2);

}

else {

System.out.println("Invalid");

}

}

}

Similar questions