Computer Science, asked by saniaparween888, 2 days ago

Write a calculator program that takes as input two numbers and one operator perform mathematical operation and prints the calculated result.​

Answers

Answered by ansulsharma
0

ANSWER

ANSWERimport java.util.Scanner;

ANSWERimport java.util.Scanner;public class KboatCalculator

ANSWERimport java.util.Scanner;public class KboatCalculator{

ANSWERimport java.util.Scanner;public class KboatCalculator{ public static void main(String args[]) {

ANSWERimport java.util.Scanner;public class KboatCalculator{ public static void main(String args[]) { Scanner in = new Scanner(System.in);

ANSWERimport java.util.Scanner;public class KboatCalculator{ public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter first number: ");

ANSWERimport java.util.Scanner;public class KboatCalculator{ public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter first number: "); int a = in.nextInt();

ANSWERimport java.util.Scanner;public class KboatCalculator{ public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter first number: "); int a = in.nextInt(); System.out.println("Enter second number: ");

ANSWERimport java.util.Scanner;public class KboatCalculator{ public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.println("Enter first number: "); int a = in.nextInt(); System.out.println("Enter second number: "); int b = in.nextInt();

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

System.out.println("Enter operator: "); char op = in.next().charAt(0);

System.out.println("Enter operator: "); char op = in.next().charAt(0); int r = 0;

System.out.println("Enter operator: "); char op = in.next().charAt(0); int r = 0; switch (op) {

case '+':

case '+': r = a + b;

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r);

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r); break;

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r); break;

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r); break; case '-':

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r); break; case '-': r = a - b;

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r); break; case '-': r = a - b; System.out.println(a + " - " + b + " = " + r);

case '+': r = a + b; System.out.println(a + " + " + b + " = " + r); break; case '-': r = a - b; System.out.println(a + " - " + b + " = " + r); break;

case '*':

case '*': r = a * b;

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r);

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break;

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break;

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break; case '/':

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break; case '/': r = a / b;

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break; case '/': r = a / b; System.out.println(a + " / " + b + " = " + r);

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break; case '/': r = a / b; System.out.println(a + " / " + b + " = " + r); break;

case '*': r = a * b; System.out.println(a + " * " + b + " = " + r); break; case '/': r = a / b; System.out.println(a + " / " + b + " = " + r); break;

default:

default: System.out.println("INVALID OPERATOR");

default: System.out.println("INVALID OPERATOR"); }

Similar questions