Program
import java.util.Scanner;
import java.util. *;
class Oct_Deci{
Scanner sc;
int num;
// Methods : 1 Using Function throgh
/*
void getVal(){
System.out.println("Octal to Decimal:");
sc = new Scanner(System.in);
System.out.println("\n Enter the number: ");
num = Integer.parseInt(sc.nextLine(),8);
}
void covnert(){
String decimal = Integer.toString(num);
System.out.println("Decimal Value is:"+decimal);
}
public static void main(String aeg[]){
Oct_Deci obj= new Oct_Deci();
obj.getVal();
obj.covnert();
}
*/
// Methods 2: Using Built- and Simple
public static void main(String args[]){
String Oct= "17";
int decimal = Integer.parseInt(Oct, 8);
System.out.println("Decimal Value is:"+decimal);
}
}
Answer:
Decimal Value is:15
0 Comments