import java.util.Scanner;
public class HexadecimalToOctal
{
private String hex;
private int dec;
private String oct;
public void setHex(String hex)
{
this.hex = hex;
}
public void getDec()
{
dec = Integer.parseInt(hex, 16);
}
public void setOct()
{
oct = Integer.toOctalString(dec);
}
public String getOct()
{
return oct;
}
public static void main(String []args)
{
HexadecimalToOctal obj = new HexadecimalToOctal();
Scanner input = new Scanner(System.in);
System.out.println("Enter a hexadecimal number : ");
obj.setHex(input.next());
obj.getDec();
obj.setOct();
System.out.println("The octal equivalent is : "+obj.getOct());
input.close();
}
}
Sometimes the only way to move forward is to revisit the things in your past that were holding you back. You have to deal with them head on, no matter how scary they may be. Because once we do, you'll see that you can go further than you ever imagined. सो जाएँगे कल लिपटकर तिरंगे के साथ अलमारी में... देशभक्ति है साहब.... तारीखों पर जागती है। The only way out is through.
Saturday, 19 March 2016
hexadecimal to octal conversion program in java
Labels:
Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment