File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes i cant crack this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "i cant crack this code" Watch "i cant crack this code" New topic
Author

i cant crack this code

Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128
my task is to use a loop,, i need the loop to go till 77777

the problem is that the numbers need to be octagon type.. 1-8 instead of 1-10. i have no idea how to make that conversion. i created 2 loops...

i tried to come up with a code for 2 hours. but no luck




it should count the numbers like that:


12345678 then add another series to this one..

12345678

so it would be 1+1 2+2 3+3.....

until it reaches 77777
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19794
    
  20

Change 77777 into 077777 - that makes it the octal representation of 32767. The loop guard would be "while (count < 0100000)". Instead of 8 you can use 010. You see, by adding a 0 before the number the compiler uses base-8*, just like adding 0x at the starts makes it base-16* or HEX. 010 is nothing more than 1*8^1 + 0*8^0, and 077777 is 7*8^4 + 7*8^3 + 7*8^2 + 7*8^1 + 7*8^0

For the purists: base-10, since everything is base-10
For those that don't get it - read it as base-one-zero, not base-ten.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128
Rob Prime wrote:Change 77777 into 077777 - that makes it the octal representation of 32767. The loop guard would be "while (count < 0100000)". Instead of 8 you can use 010. You see, by adding a 0 before the number the compiler uses base-8*, just like adding 0x at the starts makes it base-16* or HEX. 010 is nothing more than 1*8^1 + 0*8^0, and 077777 is 7*8^4 + 7*8^3 + 7*8^2 + 7*8^1 + 7*8^0

For the purists: base-10, since everything is base-10
For those that don't get it - read it as base-one-zero, not base-ten.


i did what you told me to do.. it gives me an octal representation, but i should get a decimal or some other presentation that would make the numbers reach 77777.
the instructions to do this exercise are so tricky.

i think, that the persentation should be something like that...
1
2
3
4
5
6
7
8
11
12
13
14
15
16
17
18
20
21
22
23
24
..
..
..
..
..
77775
77776
77777

i am not 100% sure.
but the instruction that i got was to make the application display all the numbers from 0 to 77777 (octal)

i think you are close to the answer, because that is how you get an octal number (8^1 2*8^2....)

but in practice how do i feed that formula into a loop, do i need one or two loops?


i need to make it so that it would add a series of 1-8 with another 1-8 until you reach 77777.

those were the instructions, to display octal numbers from 0-77777

no idea how it is done, but it must have a loop and a few basic operators



usually i use basic operators and i am learning how to use a loop. but i am not sure how to use 2 loops, cause i think in this problem i need to use 2 loops
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3742
    
  16
finding out exactly what an octal number is would be a good start.


Joanne
Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128

i am not sure if to make the conversion or not.....

should i delete the second loop? it serves no purpose


so, do you think i should leave it like that... it gives me the numbers to 777777




should i add somehting to the code to make it betteR?
Dmitri Makovetskiy
Ranch Hand

Joined: Jun 21, 2010
Posts: 128

i emailed the homework to my teacher. i have no idea, how to solve that 0-77777 exercise...

i will have to see in class..damn
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

I have made a copy of this thread and moved it to the Ranch Office forum. Any discussion of cross-posting should be take up there.

Anyone who reads this thread should know the OP has also asked this question on at least one other forum, and may have gotten his answer there.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i cant crack this code