package org.interview.test;
import java.util.Scanner;
public class Calculator {
public static void main (String [] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.println("First Number:");
int x = sc.nextInt();
System.out.println("Second Number:");
int y = sc.nextInt();
System.out.println("Mathematical Operation:");
String op = sc.next();
if(op.equalsIgnoreCase("/")) {
System.out.println(x/y);
}else if(op.equalsIgnoreCase("*")) {
System.out.println(x*y);
}else if(op.equalsIgnoreCase("+")) {
System.out.println(x+y);
}else if(op.equalsIgnoreCase("-")) {
System.out.println(x-y);
}else if(op.equalsIgnoreCase("eo")) {
if(x%2==0) {
System.out.print("X is Even");
} else {
System.out.println("X is Odd");
}
if(y%2==0) {
System.out.print("Y is Even");
} else {
System.out.println("Y is Odd");
}
}
}
}
import java.util.Scanner;
public class Calculator {
public static void main (String [] args) throws Exception {
Scanner sc = new Scanner(System.in);
System.out.println("First Number:");
int x = sc.nextInt();
System.out.println("Second Number:");
int y = sc.nextInt();
System.out.println("Mathematical Operation:");
String op = sc.next();
if(op.equalsIgnoreCase("/")) {
System.out.println(x/y);
}else if(op.equalsIgnoreCase("*")) {
System.out.println(x*y);
}else if(op.equalsIgnoreCase("+")) {
System.out.println(x+y);
}else if(op.equalsIgnoreCase("-")) {
System.out.println(x-y);
}else if(op.equalsIgnoreCase("eo")) {
if(x%2==0) {
System.out.print("X is Even");
} else {
System.out.println("X is Odd");
}
if(y%2==0) {
System.out.print("Y is Even");
} else {
System.out.println("Y is Odd");
}
}
}
}
No comments:
Post a Comment