Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program to parse and evaluate programs consisting of assignment and

ID: 3548156 • Letter: W

Question

                        Write a java program to parse and evaluate programs consisting of assignment and print statements with fully parenthesized arithmetic                         expressions. For example, given the input
                        A = 5
                        B = 10
                        C = A + B
                        D = C * C
                        print(D)
                        your program should print the value 225. Assume that all variables and values are of type double. Use a symbol table to keep track of                         variable names.                     

Explanation / Answer

import java.util.Scanner;

class AddNumbers

{

public static void main(String args[])

{

double A,B,C,D;

A = 5;

B = 10;
C = A + B;
D = C * C;

System.out.println("A = "+A);//5

System.out.println("B = "+B);//10

System.out.println("C = "+C);//15

System.out.println("D = "+D);//225

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote