Hi. I have been using the book "An Introduction to Programming Using Java," by Anthony Dos J. Reis, 2012 Edition, ISBN-13: 978-0-7637-9060-8, ISBN-10: 0-7637-9060-5. This is a textbook but I am using this on my own to learn how to program in Java. I have some prior experience with programming in different languages such as PBasic, Fortran, Pascal, Processing, and Arduino.
The last Homework question, question #4, in Chapter 6 requires the programmer to construct a program that manipulates two integers to represent rational numbers. It has a number of methods for which I have written two in the first class called <class RationalNumber> and the main method. These methods have been written to be part of the whole program and at this point include testing statements so values in the program can be monitored.
In the output there is an output statement for which I do not know the format.
Here is the whole program between the asterisks and the next part is the output, also between asterisks (the asterisks are not part of the output statements):
*****
/*
This program manipulates rational numbers by making use of ratios of integers.
*/
class RationalNumber
{
private int numerator, denominator;
//------------------------
public RationalNumber(int n, int d)
{
numerator = n;
denominator = d;
System.out.println(numerator); // test statement
System.out.println(denominator);// test statement
}
//---------------------------
public RationalNumber add(RationalNumber r)
{
return new RationalNumber(((r.numerator*denominator)+(numerat or*denominator)) , (r.denominator*denominator));
}
//---------------------------
/* public RationalNumber multiply(RationalNumber r)
{
}
//----------------------------
public void reduce()
{
}
//----------------------------
public String toString()
{
}
*/
}
//--------------------------------------
class C6h4MyEdit
{
public static void main(String[] args)
{
RationalNumber a = new RationalNumber(3, 7); // first call setting numerator = 3, denominator = 7
RationalNumber b = new RationalNumber(7, 3); // second call setting nuerator = 7, denominator = 3
RationalNumber c = b.add(a);
System.out.println(c);
}
}
*****
3
7
7
3
30
21
RationalNumber@70d1c9b5
*****
It is the last statement, RationalNumber@70d1c9b5, for which I do not know the format. Note that much of the program is commented out but included, ready to be used for programming. The methods are as stated in the question in the book. Is this some kind of location in memory or a particular format? Changing the output from RationalNumber c to RationalNumber b produces the same output statement.
I am running Java from the command line in Linux Mint 12.