Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CreditCardVerifier {
- /**
- * @param args the command line arguments
- */
- static int i=1;
- public static void main(String[] args) {
- //declare decimal and quotient variables
- int q, dec;
- Scanner scanner = new Scanner(System.in);
- System.out.println("Enter a decimal number: ");
- dec = scanner.nextInt();
- int[] oct = Octal(dec);
- int sum =0;
- for(int c=i-1;c>0;c--){
- System.out.print(oct[c]);
- int value= (int) oct[c];
- sum+=value;
- }
- // String sum1 = Integer.toString(sum);
- // System.out.println("Check the conveted sum: "+sum1);
- // while(sum1.length()>1){
- //
- // sum=
- // }
- System.out.println("The sum is: "+sum);
- }
- static int[] Octal(int q){
- //create an integer array to store the remainder
- int[] a = new int[50];
- while(q != 0){
- a[i++] = q%8;
- q=q/8;
- }
- return a;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement