Skip to content

again. no sleep. #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 28, 2021
Prev Previous commit
Next Next commit
fixing tests
  • Loading branch information
Bobbi-Z committed Jun 28, 2021
commit 60531d5e70c55137670051e7bc68c4d15f2d09b8
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public static void menuOption1() {
System.out.println("Here are some Scientific Functions. \nSine() \nCosine() \nTangent()");
break;
case "3":
String userInput = Console.getStringInput("Time for some math? \n ( Y / N )");
if(userInput.equalsIgnoreCase("Y")) {
break outerLoop;
}
String userInput = Console.getStringInput("Time for some math? \n ( Y / N )");
if (userInput.equalsIgnoreCase("Y")) {
break outerLoop;
}
break;
default:
Console.println("[ %s ] is not a valid input!", prompt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ public class CalculatorEngine {
// CalculatorEngine calculatorEngine = new CalculatorEngine();
private static Double value;

public static Double sum(Double firstNum, Double secondNum) {
value = firstNum + secondNum;
return value;
public Double sum(Double firstNum, Double secondNum) {
return firstNum + secondNum;
}

public Double subtract(Double firstNum, Double secondNum) {
value = firstNum - secondNum;
return value;
return firstNum - secondNum;
}

public Double divide(Double firstNum, Double secondNum) {
value = firstNum / secondNum;
return value;
public static Double divide(Double firstNum, Double secondNum) {
return firstNum / secondNum;
}

public Double multiply(Double firstNum, Double secondNum) {
value = firstNum * secondNum;
return value;
public static Double multiply(Double firstNum, Double secondNum) {
return firstNum * secondNum;
}

public Double squareRoot(Double firstNum){
public static Double squareRoot(Double firstNum){
double s;
double value = firstNum / 2;
do {
Expand All @@ -34,4 +31,7 @@ public Double squareRoot(Double firstNum){
return value;
}

public static Double square(Double firstNum){
return firstNum * firstNum;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

package com.zipcodewilmington.scientificcalculator;

/*
public class Scientific {

public static void main(String[] args) {
Expand Down Expand Up @@ -77,21 +77,17 @@ public static void main(String[] args) {
default
System.out.println("ERR");
}
*/public static boolean isRadian ( double input){
/* public static boolean isRadian( double input){
double to180 = (input + ((180 / Math.PI) - input));
// 57 is 180 degrees rounded to whole number
if (Math.round(to180) == 57) {
return true;
} else {
/*}return false;
return false;
}


}
}
}
//<<<<<<< master
//=======
*/


//>>>>>>> master
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.Assert;
import org.junit.Test;

import static com.zipcodewilmington.scientificcalculator.CalculatorEngine.*;


public class CalculatorEngineTest {
Expand Down Expand Up @@ -59,52 +60,55 @@ public void testSubtract2() {

@Test
public void testDivide1() {
CalculatorEngine calculatorEngine = new CalculatorEngine();
Double result;
result = calculatorEngine.divide(6.00, 3.00);
if (result != 2.00); {
Assert.fail();
}
Double expected = 100.00;
Double firstNum = 1000.00;
Double secondNum = 10.00;
Double actual = CalculatorEngine.divide(firstNum, secondNum);
Assert.assertEquals(expected, actual);
}

@Test
public void testDivide2() {
CalculatorEngine calculatorEngine = new CalculatorEngine();
Double result;
result = calculatorEngine.divide(33.33, 11.11);
if (result != 3.00); {
Assert.fail();
}
Double expected = 4.00;
Double firstNum = 20.00;
Double secondNum = 5.00;
Double actual = CalculatorEngine.divide(firstNum, secondNum);
Assert.assertEquals(expected, actual);
}

@Test
public void testMultiply1() {
CalculatorEngine calculatorEngine = new CalculatorEngine();
Double result;
result = calculatorEngine.multiply(5.00, 20.00);
if (result != 100.00); {
Assert.fail();
Double expected = 100.00;
Double firstNum = 20.00;
Double secondNum = 5.00;
Double actual = multiply(firstNum, secondNum);
Assert.assertEquals(expected, actual);
}
}


@Test
public void testMultiply2() {
CalculatorEngine calculatorEngine = new CalculatorEngine();
Double result;
result = calculatorEngine.multiply(7.00, 20.00);
if (result != 140.00); {
Assert.fail();
}
Double expected = 4.00;
Double firstNum = 2.00;
Double secondNum = 2.0;
Double actual = multiply(firstNum, secondNum);
Assert.assertEquals(expected, actual);
}

@Test
public void testSquare1(){
CalculatorEngine calculatorEngine = new CalculatorEngine();
Double result;
result = calculatorEngine.squareRoot(9.00);
if (result != 3.00);{
Assert.fail();
}
public void testSquareRoot(){
Double expected = 2.00;
Double firstNum = 4.00;
Double actual = squareRoot(firstNum);
Assert.assertEquals(expected, actual);
}

@Test
public void testSquare(){
Double expected = 16.00;
Double firstNum = 4.00;
Double actual = square(firstNum);
Assert.assertEquals(expected, actual);
}
}

Expand Down