diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/description.html b/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..97626ba --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..601f39c --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..05cb644 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3007dae --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/project-template.xml b/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/untitled/com/company/Main.class b/out/production/untitled/com/company/Main.class new file mode 100644 index 0000000..0d58a0b Binary files /dev/null and b/out/production/untitled/com/company/Main.class differ diff --git a/src/com/company/Main.java b/src/com/company/Main.java new file mode 100644 index 0000000..729524d --- /dev/null +++ b/src/com/company/Main.java @@ -0,0 +1,71 @@ +package com.company; + +import java.util.Scanner; + +public class Main { + public static void main(String[] args) + { + Scanner in = new Scanner(System.in); + while (true) { + print("Enter first number: "); + String num1 = in.nextLine(); + print("please enter second number"); + String num2 = in.nextLine(); + print("Inputs complete"); + print("Please input operator"); + print("+ , - , * or x , /"); + String op = in.nextLine(); + + switch (op) { + case "+": { + int total = add(num1, num2); + System.out.println(total); + } + case "-": { + int total = sub(num1, num2); + System.out.println(total); + } + case "x": { + int total = mul(num1, num2); + System.out.println(total); + } + case "*": { + int total = mul(num1, num2); + System.out.println(total); + } + case "/": { + int total = div(num1, num2); + System.out.println(total); + } + default: print("Unexpected value: " + op + " ...restarting program"); + } + } + } + private static void print(String text){ + System.out.println(text); + } + private static int add(String num1, String num2){ + int add1 = Integer.parseInt(num1); + int add2 = Integer.parseInt(num2); + return add1 + add2; + } + private static int sub(String num1, String num2){ + int sub1 = Integer.parseInt(num1); + int sub2 = Integer.parseInt(num2); + return sub1 - sub2; + } + private static int mul(String num1, String num2){ + int mul1 = Integer.parseInt(num1); + int mul2 = Integer.parseInt(num2); + return mul1 * mul2; + } + private static int div(String num1, String num2){ + int div1 = Integer.parseInt(num1); + int div2 = Integer.parseInt(num2); + if (div2 == 0 || div1 == 0){ + print("cant divide by zero"); + return -1; + } + return div1 / div2; + } +} \ No newline at end of file diff --git a/untitled.iml b/untitled.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/untitled.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file