Question: Help me write a java code: 1)Read quadruples from txt file ; 2)Change the quadruples into algrithm expressions; 3)Compute the final result. Quadruples: ? 1(=,1,/,x)

Help me write a java code:

1)Read quadruples from txt file ;

2)Change the quadruples into algrithm expressions;

3)Compute the final result.

Quadruples:

?

1(=,1,/,x) 2(=,2,/,y) 3(+,x,y,T1) 4(=,T1,/,z)

?

1(=,0,/,sum) 2(=,5,/,a) 3(=,4,/,b) 4(=,1,/,i) 5(<,i,11,T1) 6(FJ,T1,/,19) 7(+,sum,i,T2) 8(=,T2,/,sum) 9(=,1,/,i) 10(<,i,11,T3) 11(FJ,T3,/,17) 12(+,1,2,T4) 13(*,T4,3,T5) 14(=,T5,/,a) 15(++,i,/,i) 16(RJ,/,/,10) 17(++,i,/,i) 18(RJ,/,/,5) 19(>,a,b,T6) 20(FJ,T6,/,28) 21(=,0,/,c) 22(>,a,c,T7) 23(FJ,T7,/,26) 24(=,0,/,c) 25(RJ,/,/,27) 26(=,1,/,c) 27(RJ,/,/,29) 28(=,1,/,c)

Code I have done so far(but I didn't finish)

package compiler;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

public class Compute {

public static void main(String args[]) throws Exception {

File file = new File("C:/Users/dell-pc/Workspaces/MyEclipse 2016 CI/C-Compiler/output/Quadruple.txt");

BufferedReader br = new BufferedReader(new FileReader(file));

String s = null;

char[] id = new char[100];

int[] x = new int[100];

while((s = br.readLine())!= null)

{

//System.out.println(s);

for(int i=1;i

if(s.charAt(2)=='='){

if(Character.isDigit(s.charAt(4))){

id[i] = s.charAt(8);

if(s.charAt(6)=='/'){

x[i] = s.charAt(4);

}

}

}

else if(s.charAt(2)=='+'||s.charAt(2)=='-'||s.charAt(2)=='*'||s.charAt(2)=='/'){

if(Character.isDigit(s.charAt(4))){

}

}

}

}

br.close();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!