Computer Science, asked by AnnieStar, 9 months ago

Get input 2 numbers from user and 1 operator [+, -, *, /] and display the calculated result​

Answers

Answered by samarthkrv
1

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) throws Exception {

Scanner sc = new Scanner(System.in);

System.out.print("Enter the first number:");

int a = sc.nextInt();

System.out.print("Enter another number:");

int b = sc.nextInt();

System.out.print("Enter operator:");

char op = (char)System.in.read();

    switch(op){

        case '+':

            System.out.println(a+b);

            break;

        case '-':

            System.out.println(a-b);

            break;

        case '*':

            System.out.println(a*b);

            break;

        case '/':

            System.out.println(a/(float)b);

            break;

        default:

            System.out.println("Invalid operatrion");

            break;

    }

}

}

Explanation:

Answered by sranjita365
3

\huge\underbrace \red{{\mathbb{࿐AɴѕWєR࿐}}}

SIS, HOW TO COMMENT THE ANSWER IN BRAINY I CLICK ON COMMENT OPTION AND POST IT BUT MY COMMENTS ARE NOT SHOWING TO ME.

Explanation:

I HOPE IT'S HELPFUL FOR YOU

PLEASE DEAR MARK ME

AS BRAINLIEST ☺️☺️

KEEP LEARNING ✌️✌️

THANK YOU ❣️❣️

HAVE A NICE DAY (◕ᴗ◕✿)

Similar questions