Discuss Data structures in java in the Java Help forum on Dev Shed. Data structures in java Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
Posts: 1
Time spent in forums: 2 m 52 sec
Reputation Power: 0
Homework - 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.
Posts: 2,398
Time spent in forums: 1 Month 2 Weeks 18 h 14 m 25 sec
Reputation Power: 1660
Quote:
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.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.