Skip to content

Commit

Permalink
added all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Halqq committed Sep 16, 2022
0 parents commit 251811f
Show file tree
Hide file tree
Showing 13 changed files with 394 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Project exclude paths
/out/
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/MathResolver_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions MathResolver.iml
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>
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: dev.halq.Main

55 changes: 55 additions & 0 deletions src/dev/halq/Calculator/Calculator.java
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);

}
}
42 changes: 42 additions & 0 deletions src/dev/halq/Calculator/Utils/CalcUtil.java
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;
}
}
}
64 changes: 64 additions & 0 deletions src/dev/halq/Equation/EquationResolver.java
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");

}
}

}
51 changes: 51 additions & 0 deletions src/dev/halq/Main.java
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)");
}

}
}
Loading

0 comments on commit 251811f

Please sign in to comment.