hi everyone,

iam an IT student that tried to solve this java programming question but have many problems can anyone help me with it ?? here is the assignment ....

using java programming language, write a program that will read a java code and locate all the assignment statements.from each of these statments you will extract the variables getting a value(the one before the = operator), and all of the variables in the expression at the right-hand side.you may assume that no variable contains an embeded blank,and that each atatement is on a line by itself .

thanx all,
Mayy

Member Avatar for iamthwee

Are you allowed to use regular expressions?

yes iam allowed to use the simplest expressions,thx for replying

You should use the Scanner class to parse each line of the file. Then use the functionalities of the String class to separate the variables and values.

Use BufferedReader (1.4) class to read in each line of the file as a string and for each line, locate the position of the '=' character. Use the substring function to extract the left and right parts of the string based on the position you have got. Skip the lines which don't contain an '=' character.

This is as simple as it gets although you might need to throw in a bit of additional logic depending on the kind of output you need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.