From 922ace70f6e9a0c4ce2e6bf1af7ecb6f19d7e219 Mon Sep 17 00:00:00 2001 From: dima Date: Mon, 4 Nov 2024 18:01:40 +0300 Subject: [PATCH] initial commit --- .gitignore | 29 +++++++++++++++++++++++++++++ src/Main.java | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 .gitignore create mode 100644 src/Main.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..7d8ffc8 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,39 @@ +import java.util.Scanner; + +//TIP To Run code, press or +// click the icon in the gutter. +public class Main { + + public static void main(String[] args) { + + Scanner a = new Scanner(System.in); + int number1 = a.nextInt(); + String sing = a.next(); + int number2 = a.nextInt(); + System.out.print("Ответ:"); + + if (":" .equals(sing) && number2 != 0 ) { + float sum = (float) number1 / (float) number2; + System.out.println(sum); + } + + if (":".equals(sing) && number2 == 0) { + System.out.println("на ноль делить нельзя"); + } + + if ("+" .equals(sing)) { + int sum = number1 + number2; + System.out.println(sum); + } + + if ("-" .equals(sing)) { + int sum = number1 - number2; + System.out.println(sum); + } + + if ("*" .equals(sing)) { + int sum = number1 * number2; + System.out.println(sum); + } + } +} \ No newline at end of file