coderrohan14

Conditionals_Ques_5.java

Jun 24th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Solution {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6. int a = sc.nextInt(),b=sc.nextInt();
  7. String operation = sc.next();
  8. if(operation=="+"){
  9. System.out.println(a+b);
  10. }else if(operation=="-"){
  11. System.out.println(a-b);
  12. }else if(operation=="*"){
  13. System.out.println(a*b);
  14. }else if(operation=="/"){
  15. System.out.println(a/b);
  16. }else{
  17. System.out.println("Invalid operation");
  18. }
  19. }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment