-
Notifications
You must be signed in to change notification settings - Fork 0
/
mgwright_Octal.java
53 lines (45 loc) · 1.2 KB
/
mgwright_Octal.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Name : Matthew Wright
// Class : 1400-005
// Program # : 6
// Due Date : Tuesday, February 24th, 2009 @ 11:59 PM
//
// Honor Pledge : On my honor as a student of the University
// of Nebraska at Omaha, I have neither given nor received
// unauthorized help on this homework assignment.
//
// NAME: Matthew Wright
// NUID: 832
// EMAIL: [email protected]
// Partners: NONE
// Description: This program accepts a number and converts it into it's Octal equivalent
import java.util.Scanner;
public class mgwright_Octal
{
public static void main( String args[] )
{
int num;
Scanner in = new Scanner(System.in);
System.out.print("Please enter a number between 0 and 32767 to convert: ");
num = in.nextInt();
if(num <= 32767)
{
System.out.print("Your integer number " + num + " is ");
//Convert num to octal equivalent
System.out.print(num/(8*8*8*8));
num = num%(8*8*8*8);
System.out.print(num/(8*8*8));
num = num%(8*8*8);
System.out.print(num/(8*8));
num = num%(8*8);
System.out.print(num/8);
num = num%8;
System.out.print(num/1);
num = num%1;
System.out.print(" in octal.\n");
}
else
{
System.out.println("UNABLE TO CONVERT");
}
}
}