Compare commits
No commits in common. "190d61afe6625923ecf9810b3f9f814bd8bf5c57" and "1e439db43d382f37c2112cd681e8dc69f7e89066" have entirely different histories.
190d61afe6
...
1e439db43d
5 changed files with 53 additions and 177 deletions
|
|
@ -4,10 +4,20 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="8658cbac-7347-4046-83e8-57065c86d2b8" name="Changes" comment="Made a calculator using Switches">
|
<list default="true" id="8658cbac-7347-4046-83e8-57065c86d2b8" name="Changes" comment="updated junk java files">
|
||||||
<change afterPath="$PROJECT_DIR$/out/production/java_practice/Calculator.class" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/practice_projects/src/Calculator.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/java_practice.iml" beforeDir="false" afterPath="$PROJECT_DIR$/java_practice.iml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/Main.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/TempConverter.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/compoundInterest.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/ifStatements.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/madLibs.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/printF.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/randomNums.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/shoppingCart.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/substrings.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/trueFalse.class" beforeDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/out/production/java_practice/weightConverter.class" beforeDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
|
@ -36,10 +46,6 @@
|
||||||
"accountId": "1865e200-c7ac-4f58-baed-f72f06b5746c"
|
"accountId": "1865e200-c7ac-4f58-baed-f72f06b5746c"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
<component name="KubernetesApiPersistence"><![CDATA[{}]]></component>
|
|
||||||
<component name="KubernetesApiProvider"><![CDATA[{
|
|
||||||
"isMigrated": true
|
|
||||||
}]]></component>
|
|
||||||
<component name="McpProjectServerCommands">
|
<component name="McpProjectServerCommands">
|
||||||
<commands />
|
<commands />
|
||||||
<urls />
|
<urls />
|
||||||
|
|
@ -58,45 +64,44 @@
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Application.Calculator.executor": "Run",
|
"Application.Calculator.executor": "Run",
|
||||||
"Application.EnhancedSwitches.executor": "Run",
|
"Application.Main.executor": "Run",
|
||||||
"Application.Main.executor": "Run",
|
"Application.TempConverter.executor": "Run",
|
||||||
"Application.TempConverter.executor": "Run",
|
"Application.compountInterest.executor": "Run",
|
||||||
"Application.compountInterest.executor": "Run",
|
"Application.ifStatements.executor": "Run",
|
||||||
"Application.ifStatements.executor": "Run",
|
"Application.madLibs.executor": "Run",
|
||||||
"Application.madLibs.executor": "Run",
|
"Application.printF.executor": "Run",
|
||||||
"Application.printF.executor": "Run",
|
"Application.randomNums.executor": "Run",
|
||||||
"Application.randomNums.executor": "Run",
|
"Application.shoppingCart.executor": "Run",
|
||||||
"Application.shoppingCart.executor": "Run",
|
"Application.substrings.executor": "Run",
|
||||||
"Application.substrings.executor": "Run",
|
"Application.tempConverter.executor": "Run",
|
||||||
"Application.tempConverter.executor": "Run",
|
"Application.trueFalse.executor": "Run",
|
||||||
"Application.trueFalse.executor": "Run",
|
"Application.weightConverter.executor": "Run",
|
||||||
"Application.weightConverter.executor": "Run",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
|
||||||
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
|
"git-widget-placeholder": "main",
|
||||||
"git-widget-placeholder": "main",
|
"junie.onboarding.icon.badge.shown": "true",
|
||||||
"junie.onboarding.icon.badge.shown": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"kotlin-language-version-configured": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"nodejs_package_manager_path": "npm",
|
||||||
"nodejs_package_manager_path": "npm",
|
"project.structure.last.edited": "SDKs",
|
||||||
"project.structure.last.edited": "SDKs",
|
"project.structure.proportion": "0.15",
|
||||||
"project.structure.proportion": "0.15",
|
"project.structure.side.proportion": "0.2",
|
||||||
"project.structure.side.proportion": "0.2",
|
"settings.editor.selected.configurable": "configurable.group.language",
|
||||||
"settings.editor.selected.configurable": "configurable.group.language",
|
"to.speed.mode.migration.done": "true",
|
||||||
"to.speed.mode.migration.done": "true",
|
"vue.rearranger.settings.migration": "true"
|
||||||
"vue.rearranger.settings.migration": "true"
|
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="MoveClassesOrPackagesDialog.RECENTS_KEY">
|
<key name="MoveClassesOrPackagesDialog.RECENTS_KEY">
|
||||||
<recent name="" />
|
<recent name="" />
|
||||||
|
|
@ -120,7 +125,7 @@
|
||||||
<workItem from="1767557093354" duration="14440000" />
|
<workItem from="1767557093354" duration="14440000" />
|
||||||
<workItem from="1767678323979" duration="16130000" />
|
<workItem from="1767678323979" duration="16130000" />
|
||||||
<workItem from="1767837943314" duration="237000" />
|
<workItem from="1767837943314" duration="237000" />
|
||||||
<workItem from="1767838192168" duration="2611000" />
|
<workItem from="1767838192168" duration="55000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="updated module output folders">
|
<task id="LOCAL-00001" summary="updated module output folders">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
|
@ -250,47 +255,12 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1767824260007</updated>
|
<updated>1767824260007</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00017" summary="updated java version to 17 so I can use switched (Introduced in 14">
|
<option name="localTasksCounter" value="17" />
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1767838335498</created>
|
|
||||||
<option name="number" value="00017" />
|
|
||||||
<option name="presentableId" value="LOCAL-00017" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1767838335498</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00018" summary="Did a few base cases using enhanced switches">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1767839475258</created>
|
|
||||||
<option name="number" value="00018" />
|
|
||||||
<option name="presentableId" value="LOCAL-00018" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1767839475258</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00019" summary="Did a few base cases using enhanced switches">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1767839480914</created>
|
|
||||||
<option name="number" value="00019" />
|
|
||||||
<option name="presentableId" value="LOCAL-00019" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1767839480914</updated>
|
|
||||||
</task>
|
|
||||||
<option name="localTasksCounter" value="20" />
|
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
|
||||||
<option name="TAB_STATES">
|
|
||||||
<map>
|
|
||||||
<entry key="MAIN">
|
|
||||||
<value>
|
|
||||||
<State />
|
|
||||||
</value>
|
|
||||||
</entry>
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="updated module output folders" />
|
<MESSAGE value="updated module output folders" />
|
||||||
<MESSAGE value="moved small projects into one project folder" />
|
<MESSAGE value="moved small projects into one project folder" />
|
||||||
|
|
@ -307,10 +277,7 @@
|
||||||
<MESSAGE value="Refactored classes / File names to use Pascal case" />
|
<MESSAGE value="Refactored classes / File names to use Pascal case" />
|
||||||
<MESSAGE value="updated junk files" />
|
<MESSAGE value="updated junk files" />
|
||||||
<MESSAGE value="updated junk java files" />
|
<MESSAGE value="updated junk java files" />
|
||||||
<MESSAGE value="updated java version to 17 so I can use switched (Introduced in 14" />
|
<option name="LAST_COMMIT_MESSAGE" value="updated junk java files" />
|
||||||
<MESSAGE value="Did a few base cases using enhanced switches" />
|
|
||||||
<MESSAGE value="Made a calculator using Switches" />
|
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Made a calculator using Switches" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,59 +0,0 @@
|
||||||
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();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class EnhancedSwitches {
|
|
||||||
|
|
||||||
public static void main(String[] args){
|
|
||||||
|
|
||||||
// Enhanced swich = A replacement to using multiple else if statements
|
|
||||||
// (Introduced in Java14)
|
|
||||||
|
|
||||||
// Lets make a simple day checker that reports if it is a weekend or a weekday
|
|
||||||
|
|
||||||
Scanner scanner = new Scanner(System.in);
|
|
||||||
|
|
||||||
// Ask user for day of the week
|
|
||||||
System.out.println("What day is it today?? (Mon, Tue, etc.)?? ");
|
|
||||||
|
|
||||||
// normalize the input so we can test it easier
|
|
||||||
String day = scanner.nextLine().trim().toLowerCase().substring(0, 3);
|
|
||||||
|
|
||||||
//
|
|
||||||
switch(day){
|
|
||||||
case "mon", "tue", "wed", "thu", "fri" -> System.out.println("It is a weekday 😫");
|
|
||||||
case "sat", "sun" -> System.out.println("It is a weekend 😁!");
|
|
||||||
default -> System.out.println("Invalid day");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue