-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraghu.txt
More file actions
1 lines (1 loc) · 816 Bytes
/
raghu.txt
File metadata and controls
1 lines (1 loc) · 816 Bytes
1
import java.util.Scanner; class Converation { static String decToBinary(int dec) { String bin=""; do{ int b=dec%2; bin=b+bin; dec=dec/2; }while(dec!=0); return bin; } static String decToOctal(int dec) { String oct=""; do{ int o=dec%8; oct=o+oct; dec=dec/8; }while(dec!=0); return oct; } static String decToHexa(int dec) { String hex=""; do{ int r=dec%16; if(r<10) hex=r+hex; else hex=(char)(r+55)+hex; dec=dec/16; }while(dec!=0); return hex; } public static void main(String arg[]) { Scanner sc= new Scanner(System.in); System.out.println("enter the decimal number"); int d=sc.nextInt(); String hx=decToHexa(d); System.out.println("Hexa Decimal equalent is: "+hx); String oct=decToOctal(d); System.out.println("Octal equalent is: "+oct); String bin=decToBinary(d); System.out.println("Binary equalent is: "+bin); } }