diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 9c85c47..c4b8437 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,20 +4,10 @@
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
@@ -46,6 +36,10 @@
"accountId": "1865e200-c7ac-4f58-baed-f72f06b5746c"
}
}
+
+
@@ -64,44 +58,45 @@
- {
- "keyToString": {
- "Application.Calculator.executor": "Run",
- "Application.Main.executor": "Run",
- "Application.TempConverter.executor": "Run",
- "Application.compountInterest.executor": "Run",
- "Application.ifStatements.executor": "Run",
- "Application.madLibs.executor": "Run",
- "Application.printF.executor": "Run",
- "Application.randomNums.executor": "Run",
- "Application.shoppingCart.executor": "Run",
- "Application.substrings.executor": "Run",
- "Application.tempConverter.executor": "Run",
- "Application.trueFalse.executor": "Run",
- "Application.weightConverter.executor": "Run",
- "ModuleVcsDetector.initialDetectionPerformed": "true",
- "RunOnceActivity.MCP Project settings loaded": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
- "RunOnceActivity.git.unshallow": "true",
- "RunOnceActivity.typescript.service.memoryLimit.init": "true",
- "com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
- "git-widget-placeholder": "main",
- "junie.onboarding.icon.badge.shown": "true",
- "kotlin-language-version-configured": "true",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "project.structure.last.edited": "SDKs",
- "project.structure.proportion": "0.15",
- "project.structure.side.proportion": "0.2",
- "settings.editor.selected.configurable": "configurable.group.language",
- "to.speed.mode.migration.done": "true",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
@@ -125,7 +120,7 @@
-
+
@@ -255,12 +250,47 @@
1767824260007
-
+
+
+ 1767838335498
+
+
+
+ 1767838335498
+
+
+
+ 1767839475258
+
+
+
+ 1767839475258
+
+
+
+ 1767839480914
+
+
+
+ 1767839480914
+
+
+
+
+
@@ -277,7 +307,10 @@
-
+
+
+
+
diff --git a/out/production/java_practice/Calculator.class b/out/production/java_practice/Calculator.class
new file mode 100644
index 0000000..b8f6ea4
Binary files /dev/null and b/out/production/java_practice/Calculator.class differ
diff --git a/practice_projects/src/Calculator.java b/practice_projects/src/Calculator.java
new file mode 100644
index 0000000..e6bf6b4
--- /dev/null
+++ b/practice_projects/src/Calculator.java
@@ -0,0 +1,59 @@
+import java.util.Scanner;
+
+public class Calculator {
+
+ public static void main(String[] args){
+
+ Scanner scanner = new Scanner(System.in);
+
+ double result;
+
+ // take users first number
+ System.out.print("Enter the first number: ");
+
+ // grab both the number and a COPY of the number for Clean OUTPUT
+ String num1Input = scanner.nextLine().trim();
+ double num1 = Double.parseDouble(num1Input);
+
+ // Get the operator from the user
+ System.out.print("Enter the operator (+, -, *, /, ^): ");
+ char operator = scanner.nextLine().trim().charAt(0);
+
+ // take users second number
+ System.out.print("Enter the second number: ");
+
+ // grab both the number and a COPY of the number for Clean OUTPUT
+ String num2Input = scanner.nextLine().trim();
+ double num2 = Double.parseDouble(num2Input);
+
+ // Switch to process the operator and do the appropriate math
+ switch(operator){
+ case '+' -> result = num1 + num2;
+ case '-' -> result = num1 - num2;
+ case '*' -> result = num1 * num2;
+ case '^' -> result = Math.pow(num1, num2);
+ case '/' -> {
+ if(num2 == 0){
+ System.out.println("Cannot divide by zero!");
+ return;
+ }
+ else {
+ result = num1 / num2;
+ }
+ }
+ // Error catch if user entered something else
+ default -> {
+ System.out.println("Invalid operator!");
+ scanner.close();
+ return;
+ }
+ }
+
+ // Print out the result
+ // Use the String copies of the numbers to get clean output exactly as user entered them
+ System.out.printf("%s %c %s = %.2f", num1Input, operator, num2Input, result);
+
+ scanner.close();
+
+ }
+}