February 7th, 2013, 11:54 AM

Data structures in java
Suppose a real number is represented by java class, such as public class Real { private long left, right where left and right represent the digits to the left and right of the decimal point, respectively. If left is a negative integer, then the represented real number is negative.
a. write a routine to input a real number, and create an object representing that number.
b. write a function that accepts such a structure and returns the real number represented by it.
c. write routines add, subtract and multiply that accept two such structures and set the valure of the third structure to represent the number that is the sum, difference, and product, respectively, of the two input records.
February 7th, 2013, 11:57 AM

Originally Posted by swab1991
Suppose a real number is represented by java class, such as public class Real { private long left, right where left and right represent the digits to the left and right of the decimal point, respectively. If left is a negative integer, then the represented real number is negative.
a. write a routine to input a real number, and create an object representing that number.
b. write a function that accepts such a structure and returns the real number represented by it.
c. write routines add, subtract and multiply that accept two such structures and set the valure of the third structure to represent the number that is the sum, difference, and product, respectively, of the two input records.
Congratulations! You have successfully copied and pasted your homework and, in the process, proven that you've got nothing to show that you've even started the assignment.
If you have a question or get stuck, post that. Don't expect people do you your homework for you.
Comments on this post