Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- /*
- System.out.println("hello");
- Scanner scan = new Scanner(System.in);
- double number = scan.nextDouble();
- double text = Double.parseDouble(scan.next());
- String numberAsString = "55";
- int numberAsInteger = Integer.parseInt(numberAsString);
- System.out.println(numberAsInteger);
- //String text = scan.next();
- System.out.println("Number: " + number + " text: " + text);
- */
- Scanner scan = new Scanner(System.in);
- System.out.print("Enter operation: ");
- char op = scan.next().charAt(0);
- System.out.print("Enter first number: ");
- int numberOne = scan.nextInt();
- System.out.print("Enter second number: ");
- int numnerTwo = scan.nextInt();
- if(op == '+') {
- System.out.print(numberOne + numnerTwo);
- int sum = numberOne + numnerTwo;
- System.out.print("result: " + sum);
- }else if(op == '-') {
- if(numberOne > numnerTwo) {
- System.out.print(numberOne - numnerTwo);
- }else {
- System.out.print("Error");
- }
- }else if(op == '*') {
- System.out.print(numberOne * numnerTwo);
- }else if(op == '/') {
- if(numberOne == 0 || numnerTwo == 0) {
- System.out.print("Error");
- }else {
- System.out.print(numberOne / numnerTwo);
- }
- }else {
- System.out.print("Invalid operation !");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement