Meaty Chi

Greenhorn
+ Follow
since Feb 16, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Meaty Chi

Hi M Ford - I'm glad I could help however if you want to follow the book using the code it provided then you need to look at the solution below.

After all the bamboozling around how to print the text it was simply a case of moving the text "The reversed number is " outside the loop

12 years ago
Sorry I could have phrased that better.

the code produces the 9271 but I cannot append the text to it.
12 years ago
Finally I have it, well almost:



I am still having problems appending the text "The number reversed is " without it printing it out four times.

I have tried

and

neither produce:

"The number reversed is 9271"

Grrrrrr!
12 years ago
Here is a link to the book - it seems to be quite popular and it is used as part of the CS106a programming Methodology course at Stamford Uni.

The Art and Science of Java

Thanks again for the link reference strings, however again this topic hasn't yet been covered by the book (chapter 8) so I can only assume there is a really basic way of doing this.
12 years ago
I worked it out in pencil and have had a very rough bash at putting it into code.

This will scare you so be prepared:



so as you can see I have all the components however it is limited to a four digit integer and I don't know the syntax to print out the variables num1,num2.... in a horizontal axis.

please excuse the println strung everywhere I just left them in to show some checks.

can you tell me the syntax to display the four num(s) on a single line?
12 years ago
I don't suppose either of you have read this book?

Would it be better if I skipped over to the Oracle tutorials?
12 years ago
In that case I'll jump straight in with the arrays!
12 years ago
Hi Campbell & Jeff,

Thanks for your suggestive reading. The book doesn't delve into Arrays until chapter 10 so it looks like its a For Loop solution at this stage.

I will however come back to this problem and use arrays once I get to the grans realms of Chapter 10.

I'll have to work my way through the Oracle tutorials once I get this book finished.
12 years ago
Hi all,

NOOB in the house - Here is my first question and most probably the first of very many!

After trawling through various threads I am still at a loss as most threads I have read refer to arrays and arrays haven't been covered by the book yet.

Rather than someone providing me a solution can someone provide a hint at how to tackle the following exercise:

____________________________________________________________________________________________________


Rewrite the DigitSum program given in Figure 4-6 so that instead of adding the digits in the number, it generates the number that has the same digits in the reverse order, as illustrated by this sample run:

Here is the code I am supposed to modify



I believe I understand what the code above is doing however I have no idea of how to apply some reverse logic on it.

Many Thanks!

MeatyChi
12 years ago