Skip to content

Instantly share code, notes, and snippets.

@NickCarneiro
Created February 17, 2012 03:22
Show Gist options
  • Save NickCarneiro/1850295 to your computer and use it in GitHub Desktop.
Save NickCarneiro/1850295 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class InfAddMathEquation {
public static void main( String args[]) throws IOException {
System.out.println("Enter Numbers, Type eq to add");
double[] anArray= new double[99];
Integer position = 0;
String equals = "eq";
boolean done = false;
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(System.in));
while(done!=true){
String finish= reader.readLine();
if(equals.equals(finish)){
done=true;
if(position<0){ //this code will never get executed because position is always > 0.
position= position - 1;
Double e = anArray[position];
System.out.println("Equals " + e);
}
}
else {
System.out.println("Plus");
anArray[position]=Double.valueOf(finish);
position=position + 1;
}
}
//write code to compute and print sum here.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment