Compare commits

..

No commits in common. "190d61afe6625923ecf9810b3f9f814bd8bf5c57" and "1e439db43d382f37c2112cd681e8dc69f7e89066" have entirely different histories.

5 changed files with 53 additions and 177 deletions

View file

@ -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 @@
&quot;accountId&quot;: &quot;1865e200-c7ac-4f58-baed-f72f06b5746c&quot; &quot;accountId&quot;: &quot;1865e200-c7ac-4f58-baed-f72f06b5746c&quot;
} }
}</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": { &quot;keyToString&quot;: {
"Application.Calculator.executor": "Run", &quot;Application.Calculator.executor&quot;: &quot;Run&quot;,
"Application.EnhancedSwitches.executor": "Run", &quot;Application.Main.executor&quot;: &quot;Run&quot;,
"Application.Main.executor": "Run", &quot;Application.TempConverter.executor&quot;: &quot;Run&quot;,
"Application.TempConverter.executor": "Run", &quot;Application.compountInterest.executor&quot;: &quot;Run&quot;,
"Application.compountInterest.executor": "Run", &quot;Application.ifStatements.executor&quot;: &quot;Run&quot;,
"Application.ifStatements.executor": "Run", &quot;Application.madLibs.executor&quot;: &quot;Run&quot;,
"Application.madLibs.executor": "Run", &quot;Application.printF.executor&quot;: &quot;Run&quot;,
"Application.printF.executor": "Run", &quot;Application.randomNums.executor&quot;: &quot;Run&quot;,
"Application.randomNums.executor": "Run", &quot;Application.shoppingCart.executor&quot;: &quot;Run&quot;,
"Application.shoppingCart.executor": "Run", &quot;Application.substrings.executor&quot;: &quot;Run&quot;,
"Application.substrings.executor": "Run", &quot;Application.tempConverter.executor&quot;: &quot;Run&quot;,
"Application.tempConverter.executor": "Run", &quot;Application.trueFalse.executor&quot;: &quot;Run&quot;,
"Application.trueFalse.executor": "Run", &quot;Application.weightConverter.executor&quot;: &quot;Run&quot;,
"Application.weightConverter.executor": "Run", &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
"ModuleVcsDetector.initialDetectionPerformed": "true", &quot;RunOnceActivity.MCP Project settings loaded&quot;: &quot;true&quot;,
"RunOnceActivity.MCP Project settings loaded": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
"RunOnceActivity.typescript.service.memoryLimit.init": "true", &quot;com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1&quot;: &quot;true&quot;,
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"git-widget-placeholder": "main", &quot;junie.onboarding.icon.badge.shown&quot;: &quot;true&quot;,
"junie.onboarding.icon.badge.shown": "true", &quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
"kotlin-language-version-configured": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"nodejs_package_manager_path": "npm", &quot;project.structure.last.edited&quot;: &quot;SDKs&quot;,
"project.structure.last.edited": "SDKs", &quot;project.structure.proportion&quot;: &quot;0.15&quot;,
"project.structure.proportion": "0.15", &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
"project.structure.side.proportion": "0.2", &quot;settings.editor.selected.configurable&quot;: &quot;configurable.group.language&quot;,
"settings.editor.selected.configurable": "configurable.group.language", &quot;to.speed.mode.migration.done&quot;: &quot;true&quot;,
"to.speed.mode.migration.done": "true", &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
"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 />

View file

@ -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();
}
}

View file

@ -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();
}
}