-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 251811f
Showing
13 changed files
with
394 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Project exclude paths | ||
/out/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: dev.halq.Main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package dev.halq.Calculator; | ||
|
||
import dev.halq.Calculator.Utils.CalcUtil; | ||
|
||
import java.util.Scanner; | ||
|
||
import static dev.halq.Utils.CmdUtil.print; | ||
|
||
/** | ||
* @author Halq | ||
* @since 15/09/2022 | ||
*/ | ||
|
||
public class Calculator { | ||
|
||
public static void calculatorMain() { | ||
double firstvalue, secondvalue; | ||
|
||
String op = null; | ||
Scanner reader = new Scanner(System.in); | ||
|
||
print("Please put first number"); | ||
|
||
if (!reader.hasNextDouble()) { | ||
print("Please put valid value"); | ||
reader.hasNextDouble(); | ||
|
||
} | ||
|
||
firstvalue = reader.nextDouble(); | ||
|
||
print("Please put math operator"); | ||
|
||
op = reader.next(); | ||
|
||
if (!(op.equals("+") || op.equals("-") || op.equals("+") || op.equals("/") || op.equals("%"))) { | ||
print("Please put valid operator"); | ||
|
||
} | ||
|
||
print("Please put second number"); | ||
|
||
if (!reader.hasNextDouble()) { | ||
print("Please put valid value"); | ||
reader.hasNextDouble(); | ||
|
||
} | ||
|
||
secondvalue = reader.nextDouble(); | ||
|
||
print("Result: "); | ||
CalcUtil.calcq(op, firstvalue, secondvalue); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dev.halq.Calculator.Utils; | ||
|
||
import static dev.halq.Utils.CmdUtil.*; | ||
|
||
/** | ||
* @author Halq | ||
* @since 15/09/2022 | ||
*/ | ||
|
||
public class CalcUtil { | ||
|
||
public static void calcq(String operator, double value, double value2){ | ||
switch (operator){ | ||
|
||
case "*": | ||
calc(value * value2); | ||
break; | ||
|
||
case "+": | ||
calc(value + value2); | ||
break; | ||
|
||
case "-": | ||
calc(value - value2); | ||
break; | ||
|
||
case "/": | ||
if(value == 0 || value2 == 0) { | ||
print("Impossible to divide number by 0"); | ||
|
||
} else { | ||
calc(value / value2); | ||
|
||
} | ||
break; | ||
|
||
case "%": | ||
calc(value % value2); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package dev.halq.Equation; | ||
|
||
import java.util.Scanner; | ||
|
||
import static dev.halq.Utils.CmdUtil.print; | ||
|
||
/** | ||
* @author Halq | ||
* @since 15/09/2022 | ||
*/ | ||
|
||
public class EquationResolver { | ||
|
||
public static void main() { | ||
Scanner reader = new Scanner(System.in); | ||
|
||
double a, b, c; | ||
|
||
print("Please give me constants"); | ||
|
||
print("Ex: 2x - 3x - 5 = 0 , a: 2 b: -3 c: -5"); | ||
|
||
print("a:"); | ||
if (!reader.hasNextDouble()) { | ||
print("Please give valid value"); | ||
reader.hasNextDouble(); | ||
|
||
} | ||
|
||
a = reader.nextDouble(); | ||
|
||
print("b:"); | ||
if (!reader.hasNextDouble()) { | ||
print("Please give valid value"); | ||
reader.hasNextDouble(); | ||
|
||
} | ||
|
||
b = reader.nextDouble(); | ||
|
||
print("c:"); | ||
if (!reader.hasNextDouble()) { | ||
print("Please give valid value"); | ||
reader.hasNextDouble(); | ||
|
||
} | ||
|
||
c = reader.nextDouble(); | ||
|
||
if (a != 0) { | ||
double r = (c - b) / a; | ||
|
||
print("Answer = " + r); | ||
|
||
} else if (b == c) { | ||
print("Answer = all x"); | ||
|
||
} else { | ||
print("Invalid equation"); | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dev.halq; | ||
|
||
import dev.halq.Calculator.Calculator; | ||
import dev.halq.Equation.EquationResolver; | ||
|
||
import java.util.Scanner; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static dev.halq.Utils.CmdUtil.print; | ||
|
||
/** | ||
* @author Halq | ||
* @since 15/09/2022 | ||
*/ | ||
|
||
public class Main { | ||
|
||
|
||
public static void main(String[] args) throws InterruptedException { | ||
|
||
|
||
Scanner reader = new Scanner(System.in); | ||
|
||
String r = null; | ||
|
||
print("Welcome for my MathResolver!!" + " Made by Halq!"); | ||
TimeUnit.SECONDS.sleep(1); | ||
|
||
print("Wait.. loading MathResolver resources"); | ||
TimeUnit.SECONDS.sleep(3); | ||
|
||
print("Calculator or Equation?"); | ||
|
||
r = reader.next(); | ||
|
||
if (r.equals("Calculator")) { | ||
print("Loading calculator..."); | ||
TimeUnit.SECONDS.sleep(2); | ||
Calculator.calculatorMain(); | ||
|
||
} else if (r.equals("Equation")) { | ||
print("Loading Equation Resolver..."); | ||
TimeUnit.SECONDS.sleep(2); | ||
EquationResolver.main(); | ||
|
||
} else { | ||
print("Please put valid value (Calculator or Equation)"); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.