![]() |
|
#1
|
|||
|
|||
Converting Octal to Decimal and then Decimal to OctalI am a beginner in computer programing using java. I was given a project in my college level class to create a program to convert Octal numbers to decimal numbers and decimal numbers to octal numbers. I have specific guidelines that i have to follow but the only thing that i can not figure out is the coding for converting the numbers. If i could get information on how to do this conversion using Strings and StdIn and not using reader buffers, that would be a great help.
this is what i have so far: JAVA Code:
Last edited by LuciWiz : 27-Oct-2009 at 07:46.
Reason: Please insert your Java code between [java] & [/java] tags
|
|||
|
#2
|
||||
|
||||
Re: Converting Octal to Decimal and then Decimal to OctalQuote:
...and also check the decode() function of the Integer class. Quote:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: Converting Octal to Decimal and then Decimal to OctalWell i was told that i have Java 1.6 but when i tried to run the program that you suggested (with the scanner import) i only got this message:
Code:
also i have done extensive research on the parse-ing method and do not understand how to code it. is it possible to use some sort of array in the converting process? > |
|
#4
|
||||
|
||||
Re: Converting Octal to Decimal and then Decimal to OctalHuh?
The example runs fine for me: Code:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#5
|
|||
|
|||
Re: Converting Octal to Decimal and then Decimal to OctalSorry i had several erros while trying to run the scanner. It works fine now thank you but how will i use the scanner to help me convert from octal to decimal? sorry like i said before i am a beginner
|
|
#6
|
||||
|
||||
Re: Converting Octal to Decimal and then Decimal to OctalQuote:
JAVA Code:
Code:
EDIT: Note that the example doesn't have exception [try/catch] handling around the input retrieval, but at this point, you probably have NOT covered exceptions yet, so I left that out. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#7
|
|||
|
|||
Re: Converting Octal to Decimal and then Decimal to OctalThat Scanner import did work successfully for me but i do not think that i am allowed to use that. I think that i am supposed to go the long way around it by using this sort of method in my coding :
921/8 = 115, 921%8 = 1 115/8 = 14, 115%8 = 3 14/8 = 1, 14%8 = 6 1/8 = 0, 1%8 = 1 it may seem like a waste of time to do each of these individual steps but i think that this is what my instructor requires. if you could somehow show me how to code this to make it less of a pain to convert like this every time. Thank you. |
|
#8
|
||||
|
||||
Re: Converting Octal to Decimal and then Decimal to OctalQuote:
Quote:
__________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The