int [] ary1 = new int [100];
int [] ary2 = new int [100];
System.out.println("Enter no more than 100 integers in ascending order. To end, enter a negative number.");
int num1 = user.nextInt();
int count1 = 0;
while ((num1 > -1) && (count1 < ary1.length)){
ary1[count1] = num1;
count1++;
num1 = user.nextInt();
this is the first array.
users can enter no more than 100 integers, will stop if user entered a negative number.
if (num1 < 0){
System.out.println("Enter your second list of integers from least to greatest. To end, enter a negative number.");
int num2 = user.nextInt();
int count2 = 0;
while ((num2 > -1) && (count2 < ary2.length)){
ary2[count2] = num2;
count2++;
num2 = user.nextInt();
this is the second array.
users can enter no more than 100 integers, will end if user entered a negative number.
if (num2 < 0){
for (int one = 0; one < count1; one++){
System.out.print(ary1[one]+" ");}
print out the first list of integers
System.out.println(""); **//skip a line**
for (int two =0; two < count2; two++){
System.out.print(ary2[two]+" ");} p
rint out the second list of integers
System.out.println(""); **//skip a line**
the problem is here, it won't check if the arrays are in ascending order. ↓↓↓
int inOrder = 0;
for (int check1 = 0; check1 < count1-1; check1++){
if (ary1[check1] > ary1[check1++]){
System.out.println("Error: Array not in correct order.");
break;
}else{
inOrder = 1;
}}
for (int check2 = 0; check2 < count2-1; check2++){
if (ary2[check2] > ary2[check2++]){
System.out.println("Error: Array not in correct order.");
break;
}else{
inOrder = 1;
}}
}}
} }}}
if inOder = 1, i will need to merge the 2 arrays.