Hey, I have an Octal program I need help, I'll just copy and paste the info. Basically, my professor provides barely any help and there's restrictions to what type of code. For example, on this one, I can only use if/else statements. No arrays, no if/ands/or/nots, and no strings either.
Here it is:
For this program, you are going to convert decimal (integer) numbers into their octal number equivalents.
The input to the program will be a non-negative integer number. If the number is less than or equal to 32767, convert the number to its octal equivalent. If the number is larger than 32767, output the phrase “Unable to Convert!”
The output of your program will be a 5-digit octal number with no spaces between any of the digits. It may help to think that you may output each digit of the octal number individually as you calculate it, as long as you don't put spaces or new lines in your output between each digit.
Here are a few examples of decimal numbers and their octal number equivalents:
Decimal Number (the input from the user) Octal Equivalent (what your program would output)
Remember that your program requires a complete, digitally signed Honor Pledge to be graded.
Name your class according to the “Class and File Name” section above.
The octal number equivalent that you output should not have any spaces in it and should always be five digits.
Your program should only process one number and then quit; do not process more than one number.
Only use material through section 4.6 of the book, which includes the if and if/else structures. The if statement is the only necessary control structure, though the if/else could make your code a little more elegant.
Two Separate Sample Program Runs (user input is underlined)
Please enter a number between 0 and 32767 to convert: 2000
Your integer number 2000 is 03720 in octal.
Please enter a number between 0 and 32767 to convert: 50000
Unable to Convert!
And then here is what I have for code thus far:
public class arowlands_Octal
public static void main ( String arg )
Scanner input = new Scanner ( System.in );
System.out.print ( "Please enter a number between 0 and 32767 to convert: ");
number = input.nextInt();
if (number <= 7)
number1 = number
if (number <= 63)
number2 = number
And there's where I got lost, I just feel like I'm approaching this all wrong and am totally off track.
Thanks for any help.