//Octal to Decimal in JAVA
import java.util.Scanner;
class Octal_Decimal
{
Scanner scan;
int num;
void getVal()
{
System.out.println("Octal to Decimal");
scan = new Scanner(System.in);
System.out.println("\nEnter the number :");
num = Integer.parseInt(scan.nextLine(), 8);
}
void convert()
{
String decimal = Integer.toString(num);
System.out.println("Decimal Value is : " + decimal);
}
}
public class Oct_Dec
{
public static void main(String args[])
{
Octal_Decimal obj = new Octal_Decimal();
obj.getVal();
obj.convert();
}
}
import java.util.Scanner;
class Octal_Decimal
{
Scanner scan;
int num;
void getVal()
{
System.out.println("Octal to Decimal");
scan = new Scanner(System.in);
System.out.println("\nEnter the number :");
num = Integer.parseInt(scan.nextLine(), 8);
}
void convert()
{
String decimal = Integer.toString(num);
System.out.println("Decimal Value is : " + decimal);
}
}
public class Oct_Dec
{
public static void main(String args[])
{
Octal_Decimal obj = new Octal_Decimal();
obj.getVal();
obj.convert();
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.