Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cc839be
core features, still working on tests
JennStaciCodes Jul 12, 2025
e4a3a8f
Added clear and Test applicaitions
JennStaciCodes Jul 12, 2025
ab2729c
Finish
JennStaciCodes Jul 12, 2025
09b7783
Added detailed comments so we can better understand each function
JennStaciCodes Jul 12, 2025
28b4328
set options took user input
Frank-Montgomery-Jr Jul 12, 2025
fccdc99
push before we leave
JennStaciCodes Jul 12, 2025
0fb708c
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
Frank-Montgomery-Jr Jul 12, 2025
7af3dd9
added switch statements and got some of the functions working
Frank-Montgomery-Jr Jul 12, 2025
0111c20
almost finished scientific methods
Danishahsancs Jul 13, 2025
cd3aef3
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
Danishahsancs Jul 13, 2025
6d62eaa
added, divide, up to switch sign
Frank-Montgomery-Jr Jul 13, 2025
a03f172
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
Frank-Montgomery-Jr Jul 13, 2025
ccc3b54
finished function case 1-8
Frank-Montgomery-Jr Jul 13, 2025
9e40980
finished cases 8-18
Danishahsancs Jul 13, 2025
7541278
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
Danishahsancs Jul 13, 2025
0aac334
Added new features and fixed core
JennStaciCodes Jul 13, 2025
3e81eab
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
JennStaciCodes Jul 13, 2025
d94a738
New features test applications
JennStaciCodes Jul 13, 2025
c655601
fixed memmory recall and implemened converter onto franks code
Danishahsancs Jul 13, 2025
0ef3432
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
Danishahsancs Jul 13, 2025
ef86da5
finished
JennStaciCodes Jul 13, 2025
c0d6093
fixed sum bugs
Danishahsancs Jul 13, 2025
d60ca36
Merge branch 'master' of https://github.com/Danishahsancs/Calc-java
Danishahsancs Jul 13, 2025
f3b1d10
fixed percent issue
Danishahsancs Jul 13, 2025
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
1 change: 1 addition & 0 deletions Calc-java
Submodule Calc-java added at 0ef343
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@ public static void println(String output, Object... args) {

public static String getStringInput(String prompt) {
Scanner scanner = new Scanner(System.in);
println(prompt);
print(prompt);
String userInput = scanner.nextLine();
//scanner.close();
return userInput;
}

public static Integer getIntegerInput(String prompt) {
return null;
Scanner scanner = new Scanner(System.in);
print(prompt);
Integer userinput = scanner.nextInt();
//scanner.close();
return userinput;
}

public static Double getDoubleInput(String prompt) {
return null;
Scanner scanner = new Scanner(System.in);
print(prompt);
Double userinput = scanner.nextDouble();
//scanner.close();
return userinput;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package com.zipcodewilmington.scientificcalculator;

public class CoreFeatures {

//a state represening the value currently displayed on the calc
private double displayValue;

//Update the display to ERR if an error occurs (ex: divide by 0)
private boolean errorState;

//initiate calculator with 0 as default
public CoreFeatures () {
this.displayValue = 0.0;
//not an ERR
this.errorState=false;

}

//Get the current # on the display
public double getDisplayValue() {
//pull the display value
return this.displayValue;
}

//Check for errors
public boolean inErrorState() {
//pull the error state (is it true or false)
return this.errorState;
}

//Set display to the number entered
public void setDisplay (double value) {
//(if ERR, skip the equation)
if (checkError()) return;
//reset the display value to the number entered
this.displayValue=value;

}

//Clear the display
public void clear () {

//set display to 0 and remove error
this.displayValue=0.0;
this.errorState=false;


// Clear terminal by printing lines to simulate clearing
for (int i = 0; i < 50; ++i) {
System.out.println();
}
System.out.println("Cleared");
}


//Add (if ERR, skip the equation)
public void add(double number) {
if (checkError()) return;
this.displayValue+=number;
}


//Subtract (if ERR, skip the equation)
public void subtract (double number) {
if (checkError()) return;
this.displayValue -= number;
}

//Multiply (if ERR, skip the equation)
public void multiply (double number) {
if (checkError()) return;
this.displayValue *= number;
}

//Divide (if ERR, skip the equation)
public void divide(double number) {
if (checkError()) return;
if(number ==0) {
setError();
return;
}
this.displayValue/=number;
}

//Caclulate the square (if ERR, skip the equation)
public void square () {
if (checkError()) return;
this.displayValue=this.displayValue*this.displayValue;
}

//Calculate the square root (if ERR, skip the equation)
public void squareRoot() {
if (checkError()) return;
if (this.displayValue<0) {
setError();
return;
}
this.displayValue=Math.sqrt((this.displayValue));
}

//Calculate the variable exponentiation (if ERR, skip the equation)
public void exponentiation(double exponent) {
if (checkError()) return;
this.displayValue=Math.pow(this.displayValue, exponent);
}

//Calculate the inverse of the number (if ERR, skip the equation)
public void inverse() {
if (checkError()) return;
if (this.displayValue==0) {
setError();
return;
}
this.displayValue=1/this.displayValue;
}

//Caclulate the percentage of another number NEW FEATURE #1
public void percentage(double percent) {
if (checkError()) return;
this.displayValue = (percent/this.displayValue)*100;

}

//Takes a decimal and returns the percentage NEW FEATURE #2
public void decimalToPercentage () {
if (checkError()) return;
this.displayValue*=100;

}

//Invert the sign of the number (switch between postive and negative)
//(if ERR, skip the equation)
public void inverseSign() {
if (checkError()) return;
this.displayValue=-this.displayValue;

}


//Set an error state so we can use it to compare
private void setError() {
this.errorState=true;
}

//check for an error before operation
private boolean checkError() {
if (this.errorState) {
System.out.println("ERR");
return true;
}
return false;
}


}
Loading