I'm having issues adding the numbers in the array together. I know I need a loop to start at position 19 and move downward...but I'm at a loss...
any help would be greatly appreciated...I'm pulling my hair out.
importjava.util.Scanner;
publicclass LargeNums {
publicstaticfinalintMAXSIZE = 20;
publicstaticvoid main(String[] args) {
Scanner keyboard = new Scanner(System.in);
char x ,y;
int c1 = MAXSIZE - 1;
String input1, input2;
int [] num1 = newint[MAXSIZE];
int [] num2 = newint[MAXSIZE];
int [] num3 = newint[MAXSIZE];
System.out.println("Please enter two positive integers with less than " + MAXSIZE + " digits" );
System.out.print("Please enter the first integer: ");
input1 = keyboard.nextLine();
System.out.print("Please enter the second integer: ");
input2 = keyboard.nextLine();
for (int i= input1.length() -1; i>= 0; i--){
x = input1.charAt(i);
if(Character.isDigit(x)){
num1[c1--] = x-48;
}
}
for (int i= input1.length() -1; i>= 0; i--){
y = input1.charAt(i);
if(Character.isDigit(y)){
num2[c1--] = y-48;
}
}
for (int z = 0; z<num1.length; z++){
System.out.print(num1[z]);
}
}
}




Bookmarks