package com.ecsgrid;
import java.io.*;
public class testC {
public static void main(String[] args) {
int i = 0,j = 0;
double result, values[] = new double[4];
char k, operators[] = new char[3];
for (i = 0; i <= 2; i++)
operators[i] = '+'; // default is to add the values
File myfile;
StreamTokenizer tok;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String InputText;
i = 0;
try {
myfile = new File("C:\\VarValPairs.txt");
tok = new StreamTokenizer(new FileReader(myfile));
tok.eolIsSignificant(false);
while ((tok.nextToken() != StreamTokenizer.TT_EOF) && (i <= 3)){
if ((tok.ttype == StreamTokenizer.TT_NUMBER)){
values[i++] = tok.nval;
}
}
}
catch(FileNotFoundException e) { System.err.println(e); return; }
catch(IOException f) { System.out.println(f); return; }
System.out.println("Enter letters and operators:");
try {
InputText = in.readLine();
}
catch(IOException f) { System.out.println(f); return; }
for (i = 0; i < InputText.length(); i++)
{
k = InputText.charAt(i);
if ((k == '+') || (k == '-'))
{
{ if (j <= 2) operators[j++] = k;
}
}
result = values[0];
System.out.println("1res="+result);
for (i = 0; i <= 2; i++)
{
if (operators[i] == '+')
}
{
result = result + values[i+1];
System.out.println("2res="+result);
}
else {
result = result - values[i+1];
System.out.println("3res="+result);
}
{
System.out.println("4res="+result);
}
I am still getting the x's this is getting so frustrating. Maybe I shouldn't attempt to learn Java. I just dont know