Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
- \
- char ch = '+';
- while(ch!='x'&&ch!='X'){
- ch = sc.next().charAt(0);
- switch(ch){
- case '+':{
- long n1 = sc.nextLong();
- long n2 = sc.nextLong();
- long res = n1+n2;
- System.out.println(res);
- break;
- }
- case '-':{
- long n1 = sc.nextLong();
- long n2 = sc.nextLong();
- long res = n1-n2;
- System.out.println(res);
- break;
- }
- case '*':{
- long n1 = sc.nextLong();
- long n2 = sc.nextLong();
- long res = n1*n2;
- System.out.println(res);
- break;
- }
- case '/':{
- long n1 = sc.nextLong();
- long n2 = sc.nextLong();
- long res = n1/n2;
- System.out.println(res);
- break;
- }
- case '%':{
- long n1 = sc.nextLong();
- long n2 = sc.nextLong();
- long res = n1%n2;
- System.out.println(res);
- break;
- }
- case 'x': case 'X' :{
- sc.close();
- break;
- }
- default:{
- System.out.println("Invalid operation. Try again.");
- break;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment