Created
February 17, 2012 03:22
-
-
Save NickCarneiro/1850295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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