Skip to content

Commit 836ac70

Browse files
authored
Merge branch 'master' into master
2 parents 7882cfa + 91eb470 commit 836ac70

File tree

13 files changed

+199
-147
lines changed

13 files changed

+199
-147
lines changed

.DS_Store

6 KB
Binary file not shown.

src/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/.idea/modules.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/zipcodewilmington/scientificcalculator/Calculator.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,4 @@ public int subtract(int firstNum, int secondNum) {
1313
result = firstNum - secondNum;
1414
return result;
1515
}
16-
/*<<<<<<< HEAD
17-
18-
//>>>>>>> 67032e40a3e1b20aaf10917261cc55a57dbfe45b
1916
}
20-
=======
21-
22-
>>>>>>> 009177cc9de68c1f0401d32805d4a54e699cc1e5
23-
*/
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
package com.zipcodewilmington.scientificcalculator;
22

33
public class CalculatorDisplay {
4+
5+
public static void menuOption1() {
6+
String prompt;
7+
do {
8+
prompt = Console.getStringInput("");
9+
switch (prompt.toLowerCase()) {
10+
case "1":
11+
System.out.println("Here are some Basic Functions. \n(+) - Addition \n(-) - Subtraction \n(/) - Division \n(*) - Multiplication");
12+
break;
13+
case "2":
14+
System.out.println("Here are some Scientific Functions. \nSine() \nCosine() \nTangent()");
15+
break;
16+
case "3":
17+
System.out.println("Return to menu? \n ( Y / N?)");
18+
Console.getStringInput("");
19+
break;
20+
default:
21+
Console.println("[ %s ] is not a valid input!", prompt);
22+
break;
23+
}
24+
} while (true);
25+
}
426
}
Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,25 @@
11
package com.zipcodewilmington.scientificcalculator;
22

33
public class CalculatorEngine {
4-
CalculatorEngine calculatorEngine = new CalculatorEngine();
4+
// CalculatorEngine calculatorEngine = new CalculatorEngine();
5+
private static Double value;
56

6-
public void run(){
7-
Console.println("Welcome to the calculator!\nWhat would you like to do?");
8-
Console.println("1. Basic Functions \n2. Scientific Functions \n3. Something Fun!");
9-
menuOption1();
7+
public static Double sum(double firstNum, double secondNum) {
8+
value = firstNum + secondNum;
9+
return value;
1010
}
11-
12-
13-
public void menuOption1() {
14-
String firstChoice;
15-
do {
16-
firstChoice = Console.getStringInput("1, 2, 3");
17-
switch (firstChoice.toLowerCase()) {
18-
case "1":
19-
System.out.println("Here are some Basic Functions. \n+ \nAddition , - \n-Subtraction , / \n-Division , * \n-Multiplication");
20-
break;
21-
case "2":
22-
System.out.println("Here are some Scientific Functions. \nSine() \nCosine()");
23-
break;
24-
case "3":
25-
System.out.println("Something Fun!");
26-
break;
27-
default:
28-
Console.println("[ %s ] is not a valid input!", firstChoice);
29-
break;
30-
}
31-
} while (true);
11+
public Double subtract(Double firstNum, Double secondNum) {
12+
value = firstNum - secondNum;
13+
return value;
3214
}
3315

34-
private static int result;
35-
36-
public static int sum(int firstNum, int secondNum) {
37-
result = firstNum + secondNum;
38-
return result;
16+
public Double divide(Double firstNum, Double secondNum) {
17+
value = firstNum / secondNum;
18+
return value;
3919
}
4020

41-
public int subtract(int firstNum, int secondNum) {
42-
result = firstNum - secondNum;
43-
return result;
21+
public Double multiply(double firstNum, double secondNum) {
22+
value = firstNum * secondNum;
23+
return value;
4424
}
45-
46-
4725
}

src/main/java/com/zipcodewilmington/scientificcalculator/Console.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public static Integer getIntegerInput(String prompt) {
3333
}
3434

3535
public static Double getDoubleInput(String prompt) {
36-
return null;
36+
Scanner scanner = new Scanner(System.in);
37+
System.out.println(prompt);
38+
Double userInput = scanner.nextDouble();
39+
return userInput;
3740
}
3841
}
Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,42 @@
11
package com.zipcodewilmington.scientificcalculator;
2-
32
import java.util.Scanner;
43

54
/**
65
* Created by leon on 2/9/18.
76
*/
87
public class MainApplication {
98

9+
private CalculatorEngine engine = new CalculatorEngine();
10+
private CalculatorDisplay display = new CalculatorDisplay();
11+
1012
public static void main(String[] args) {
11-
public class Console =
12-
CalculatorEngine = new CalculatorEngine();
13-
}
14-
}
13+
System.out.println("Welcome! \nWhat would you like to do?");
14+
System.out.println("1. Basic Functions \n2. Scientific Functions \n3. Return to Menu");
15+
CalculatorDisplay.menuOption1();
1516

1617

17-
public static String menuOption1() {
18-
String prompt;
19-
prompt = Console.getStringInput("1, 2, 3");
20-
switch () {
21-
case "1":
22-
System.out.println("Here are some Basic Functions. \n+ \nAddition , - \n-Subtraction , / \n-Division , * \n-Multiplication");
23-
break;
24-
case "2":
25-
System.out.println("Here are some Scientific Functions. \nSine() \nCosine() \nTangant");
26-
break;
27-
case "3":
28-
System.out.println("Something Fun!");
29-
break;
30-
default:
31-
Console.println("[ %s ] is not a valid input!", prompt);
32-
break;
33-
}
18+
// String s = Console.getStringInput("Enter a string");
19+
String s = Console.getStringInput("Enter a string");
20+
// String s = Console.getStringInput("Enter a string");
21+
// String s = CalculatorEngine.getStringInput("Enter a string");
22+
Double d = Console.getDoubleInput("Enter a double.");
23+
Console.println("The user input %s as a string", s);
24+
// Console.println("The user input %s as a integer", i);
25+
Console.println("The user input %s as a d", d);
3426

3527

28+
}
29+
}
30+
3631
/*
3732
3833
System.out.println("Please enter a number");
39-
40-
y = scanObject.nextInt();
41-
scanObject.nextLine();
42-
4334
// System.out.println(y);
4435
// Connected the sum method
4536
System.out.println("Please enter another number");
46-
z = scanObject.nextInt();
47-
// scanObject.nextLine();
48-
4937
System.out.println("Adding now...");
5038
int x = Calculator.sum(y, z);
5139
System.out.println(x);
52-
53-
54-
String s = Console.getStringInput("Enter a string");
55-
String s = Console.getStringInput("Enter a string");
56-
String s = CalculatorEngine.getStringInput("Enter a string");
57-
58-
Double d = Console.getDoubleInput("Enter a double.");
59-
60-
Console.println("The user input %s as a string", s);
61-
// Console.println("The user input %s as a integer", i);
62-
Console.println("The user input %s as a d", d);
63-
} */
40+
}
41+
*/
6442

0 commit comments

Comments
 (0)