fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scan = new Scanner (System.in);
  13. String statement = ("Enter a number in base 8:");
  14. int [] digit = new int[8];
  15. int length,
  16. n = 0,
  17. number = 0,
  18. answer = 0;
  19. double temp = 0;
  20. double decimal = 0;
  21. double pv = 0;
  22.  
  23. //asks for an int, sets temp as the number and gets the length of number.
  24.  
  25. number = scan.nextInt();
  26. System.out.println(statement);
  27. temp = number;
  28. length = String.valueOf(number).length();
  29.  
  30. //checks if the length is greater than 8, if so it stops.
  31.  
  32. if (length > 8){
  33. System.out.print("ERROR: Incorrect Octal Format");
  34. //break;
  35. }
  36. }
  37. }
Success #stdin #stdout 0.07s 2184192KB
stdin
123
stdout
Enter a number in base 8: