Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
f46e8aa
Another test
Feb 7, 2020
38d58aa
Branches added
Feb 7, 2020
97fdac8
Branches added
Feb 8, 2020
20c420a
Attempted to add branches?
Feb 8, 2020
1a99ecb
tracking adding to sandy branch
Feb 8, 2020
449656c
Delete seed
snmangalam2708 Feb 8, 2020
6d30b31
Silly test
Feb 8, 2020
64da807
Merge pull request #1 from jwilkinson6179/james
jwilkinson6179 Feb 8, 2020
ebc6614
Create seed
snmangalam2708 Feb 8, 2020
c3351e9
sandy
Feb 8, 2020
5c6a06a
Delete seed
snmangalam2708 Feb 8, 2020
277e774
remove sed2
Feb 8, 2020
5791ccc
Delete seed2
snmangalam2708 Feb 8, 2020
0976179
added seed3
Feb 8, 2020
32e0d4a
Merge branch 'sandy' of https://github.com/jwilkinson6179/ScientificC…
Feb 8, 2020
53845bf
check
Feb 8, 2020
9448eb0
gr8ness
Feb 8, 2020
9a2edeb
remove gr8
Feb 8, 2020
3ffeeed
test
Feb 8, 2020
3115773
adding hello
Feb 8, 2020
b662544
Small comment edit
Feb 8, 2020
c7d636f
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 8, 2020
877626e
.
Feb 8, 2020
aebe5d3
Memory added
Feb 8, 2020
33dfc4e
Memory working and tested
Feb 8, 2020
5853356
Merge pull request #2 from jwilkinson6179/james
jwilkinson6179 Feb 8, 2020
efe63f9
Merge pull request #3 from snmangalam2708/sandy
jwilkinson6179 Feb 8, 2020
adfaf1b
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 8, 2020
3f42927
Testing push
Feb 8, 2020
e601b3a
Merge pull request #4 from jwilkinson6179/zanetta
jwilkinson6179 Feb 8, 2020
258dba8
Building basic math methods and tests
Feb 8, 2020
629576e
Merge pull request #5 from jwilkinson6179/zanetta
jwilkinson6179 Feb 8, 2020
369df63
Please don't kill me
Feb 8, 2020
4727ee3
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 8, 2020
420bd2a
Added eight new basic math methods, and seven additional test cases.
Feb 9, 2020
9d2a3fe
Merge pull request #6 from jwilkinson6179/zanetta
jwilkinson6179 Feb 9, 2020
a9c39a1
About to pull dev
Feb 9, 2020
9110355
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
7b6c3bb
Done for the night
Feb 9, 2020
dd97db4
added more test cases for basic math
Feb 9, 2020
20412ea
BoxMaker untested
Feb 9, 2020
6413303
Changed display, broke tests
Feb 9, 2020
a12ff3e
Test cases for display
Feb 9, 2020
bd6cce4
BoxMaker tests
Feb 9, 2020
fb9393f
Merge pull request #7 from jwilkinson6179/james
jwilkinson6179 Feb 9, 2020
e1e1c73
Sleep
Feb 9, 2020
414e2bb
Adding Trig/Log/OtherFunctions
Feb 9, 2020
b368437
AddedConversion Math Class and Conversion Math Test Class
Feb 9, 2020
75e16f5
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
857587d
final
Feb 9, 2020
47ab677
Merge pull request #8 from jwilkinson6179/sandy
jwilkinson6179 Feb 9, 2020
ba2ba6c
Nervous about pull
Feb 9, 2020
88e283d
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
3667181
minor changes
Feb 9, 2020
b282193
Added Feet to Meters conversion
Feb 9, 2020
d41fcc5
Minor changes
Feb 9, 2020
139b464
Minor changes
Feb 9, 2020
82ed978
Minor changes
Feb 9, 2020
00c0a94
Merge pull request #9 from jwilkinson6179/sandy
snmangalam2708 Feb 9, 2020
ea2f3b1
Pull from dev
Feb 9, 2020
bf2ee27
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
eddbc27
Adding valid operations
Feb 9, 2020
264706d
Fixed the test cases to evaluate to four decimal places
Feb 9, 2020
026401c
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
f1909a5
Merge pull request #10 from jwilkinson6179/zanetta
jwilkinson6179 Feb 9, 2020
bf9d64a
Pulling from dev
Feb 9, 2020
b8c014f
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
5653206
BasicMath and Conversion Math methods and tests complete. All tests p…
Feb 9, 2020
cefdf7c
Need to fix modes
Feb 9, 2020
90d16ec
Merge pull request #11 from jwilkinson6179/zanetta
jwilkinson6179 Feb 9, 2020
82b5d36
Merge trouble
Feb 9, 2020
27527b9
Merge branch 'dev' of https://github.com/jwilkinson6179/ScientificCal…
Feb 9, 2020
5898407
More cases
Feb 9, 2020
9a29de1
Lots of bugs
Feb 9, 2020
143797c
Merge pull request #12 from jwilkinson6179/james
jwilkinson6179 Feb 9, 2020
74b85fb
Fixed conversion
Feb 9, 2020
2301631
Merge pull request #13 from jwilkinson6179/james
jwilkinson6179 Feb 9, 2020
f7b525d
Final submission for demo
Feb 10, 2020
b439a38
Merge pull request #14 from jwilkinson6179/james
jwilkinson6179 Feb 10, 2020
fabeca5
Merge pull request #15 from jwilkinson6179/dev
jwilkinson6179 Feb 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Hello.txt
Empty file.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ScientificCalculator (maven) ZCW


## James
## Description

In this project your team will build a small app to function as a calculator. This app will be built in Java, and will use the topics and techniques discussed during the week.
Expand Down Expand Up @@ -63,7 +63,7 @@ Each operation should automatically update the display
- Ln (natural logarithm)
- e<sup>x</sup> (inverse natural logarithm)
- Factorial function

//

### Custom Features

Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<groupId>com.zipcodewilmington</groupId>
<artifactId>scientific_calculator</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<<<<<<< HEAD
<version>RELEASE</version>
=======
<version>4.12</version>
>>>>>>> fb9393f6415e572d2b4750a4662a151dc5895047
<scope>test</scope>
</dependency>
</dependencies>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.zipcodewilmington.scientificcalculator;

public class BasicMath {
// two operator methods
public static Double addition (Double numberOne, Double numberTwo) {
return (numberOne + numberTwo);
}
public static Double subtraction (Double numberOne, Double numberTwo) {
return numberOne - numberTwo;
}
public static Double multiplication (Double numberOne, Double numberTwo) {
return numberOne * numberTwo;
}
public static Double division (Double numberOne, Double numberTwo) {
return numberOne / numberTwo;
}
public static Double exponent (Double numberOne, Double numberTwo){
return Math.pow(numberOne, numberTwo);
}
// one operator methods

public static Double square (Double numberOne) {
return numberOne * numberOne;
}
public static Double squareroot (Double numberOne){
return (Math.sqrt(numberOne));
}
public static Double inverse(Double numberOne){
return 1/numberOne;
}
}




Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.zipcodewilmington.scientificcalculator;

import java.util.ArrayList;

public class BoxMaker {
private int width;

public BoxMaker() {
width = 30;
}

public BoxMaker(int initialWidth)
{
width = initialWidth;
}

public int getWidth() {
return width;
}

public void setWidth(int newWidth)
{
if(newWidth > 3 && newWidth < 151)
{
width = newWidth;
}
}

public String draw(String ... input) {
StringBuilder output = new StringBuilder();

output.append("╔");
for (int i = 0; i < width - 2; i++) {
output.append("═");
}
output.append("╗\n");

for (String element : input) {
String line = "";
StringBuilder lineFormat = new StringBuilder();
lineFormat.append("%");
lineFormat.append(width - 2);
lineFormat.append("s");

line = String.format(lineFormat.toString(), element);
output.append("║");
output.append(line);
output.append("║\n");
}

output.append("╚");
for (int i = 0; i < width - 2; i++) {
output.append("═");
}
output.append("╝\n");

return output.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ public static String getStringInput(String prompt) {
}

public static Integer getIntegerInput(String prompt) {
return null;
Scanner scanner = new Scanner(System.in);
println(prompt);
String userInput;
userInput = scanner.nextLine();
return Integer.parseInt(userInput);
}

public static Double getDoubleInput(String prompt) {
return null;
Scanner scanner = new Scanner(System.in);
println(prompt);
String userInput;
userInput = scanner.nextLine();
return Double.parseDouble(userInput);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.zipcodewilmington.scientificcalculator;

public class ConversionMath {

public static Double feetToMeters (Double numberOne) {
return numberOne / 3.2810;
}
public static Double metersToFeet (Double numberOne) {
return numberOne * 3.28084;
}
public static Double poundsToKilos(Double numberOne) {
return numberOne / 2.205;
}
public static Double kilosToPounds(Double numberOne) {
return numberOne * 2.205;
}
public static Double fahrenheitToCelsius (Double numberOne) {
return ((numberOne - 32) * 5 / 9);
}
public static Double celsiusToFahrenheit (Double numberOne) {
return ((numberOne * 9 / 5) + 32);
}


}


164 changes: 164 additions & 0 deletions src/main/java/com/zipcodewilmington/scientificcalculator/Display.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
package com.zipcodewilmington.scientificcalculator;

import javax.swing.*;
import java.io.DataInput;

public class Display {
private int displayWidth;
private BoxMaker displayBox;
private Double currentValue;
// private String currentOperation; Moving to input
public enum Modes { BINARY, OCTAL, DEC, HEX }
private Modes mode;
private Boolean isRadians;
Boolean error;

public Display()
{
currentValue = 0.0;
mode = Modes.DEC;
displayWidth = 50;
displayBox = new BoxMaker(displayWidth);
isRadians = false;
error = false;
}

public void setDisplay(Double inputValue)
{
if (inputValue.isNaN() || inputValue.isInfinite())
{
error = true;
}
else {
currentValue = inputValue;
}
}

public Double getDisplay()
{
return currentValue;
}

// Future implimentation, running out of time to format correctly with DEG/RAD and
// BINARY/OCTAL/HEX left-justification on display
public void setDisplayWidth(int newWidth)
{
displayWidth = newWidth;
}

public String update() {
String output = "";
String radianLine = "";
String valueLine = "";
String baseLine = "";

if (error) {
radianLine = String.format("%-46s", "ERR");
valueLine = "ERR ";
baseLine = String.format("%-46s", "ERR");
output = displayBox.draw(radianLine, valueLine, baseLine);
} else {
if (isRadians == true) {
radianLine = String.format("%-46s", "RAD");
} else {
radianLine = " ";
}


// This needs to be fixed
if (mode == Modes.BINARY) {
baseLine = String.format("%-46s", "BIN");
valueLine = Integer.toBinaryString(currentValue.intValue()) + " ";
} else if (mode == Modes.OCTAL) {
baseLine = String.format("%-46s", "OCTAL");
valueLine = Integer.toOctalString(currentValue.intValue()) + " ";
} else if (mode == Modes.DEC) {
if (currentValue % 1 == 0) // No decimal
{
valueLine = Integer.toString(currentValue.intValue()) + " ";
} else {
valueLine = Double.toString(currentValue) + " ";
}
} else if (mode == Modes.HEX) {
baseLine = String.format("%-46s", "HEX");
valueLine = Integer.toHexString(currentValue.intValue()) + " ";
}
}

output = displayBox.draw(radianLine, valueLine, baseLine);
Console.println("%s", output);
return output;
}

public void setMode(Modes newMode)
{
mode = newMode;
}

public void setMode() {
switch (mode)
{
case DEC:
setMode(Modes.BINARY);
break;
case BINARY:
setMode(Modes.OCTAL);
break;
case OCTAL:
setMode(Modes.HEX);
break;
case HEX:
setMode(Modes.DEC);
break;
}

// Considering updating currentVal here, but makes math more difficult
// since Math assumes decimal math.
}

public Modes getMode()
{
return mode;
}

public void clear() {
currentValue = 0.0;
error = false;
isRadians = false;
mode = Modes.DEC;
// Send a command to input to remove last operation and last value input
}

public void invSign()
{
currentValue *= -1.0;
}

public Double absoluteValue()
{
if(currentValue < 0)
{
return currentValue * -1;
}
else
{
return currentValue;
}
}

public void toggleRadians()
{
isRadians = !isRadians;
}

public Boolean getIsRadians()
{
return isRadians;
}

public Boolean getErr() {
return error;
}

// Make a toggle to switch from normal notation to scientific notation
}
Loading