Skip to main content

Overview

The program requires 14 integer values in total:
  • 7 integers for the first array
  • 7 integers for the second array
All values must be entered interactively when prompted.

Input Prompts

When you run the program, you’ll see the following prompts from Main.java:14-26:

First Array Input

Ingrese 7 valores para el primer arreglo
Valor 1: 
Valor 2: 
Valor 3: 
Valor 4: 
Valor 5: 
Valor 6: 
Valor 7: 

Second Array Input

Ingrese 7 valores para el segundo arreglo
Valor 1: 
Valor 2: 
Valor 3: 
Valor 4: 
Valor 5: 
Valor 6: 
Valor 7: 

Input Requirements

The program uses Scanner.nextInt() to read values, which only accepts integer values (whole numbers).

Valid Input

  • Positive integers: 1, 42, 1000
  • Negative integers: -5, -100, -23
  • Zero: 0

Invalid Input

The following inputs will cause an InputMismatchException and crash the program:
  • Decimal numbers: 3.14, 5.5
  • Text or letters: abc, hello
  • Special characters: @, #, $
  • Empty input (just pressing Enter)

Example Input Session

Here’s a complete example of entering values:
Ingrese 7 valores para el primer arreglo
Valor 1: 10
Valor 2: 20
Valor 3: 30
Valor 4: 40
Valor 5: 50
Valor 6: 60
Valor 7: 70
Ingrese 7 valores para el segundo arreglo
Valor 1: 5
Valor 2: 10
Valor 3: 15
Valor 4: 20
Valor 5: 25
Valor 6: 30
Valor 7: 35

How Input is Processed

The program processes your input as follows:
1

Read first array values

The program reads 7 integers into array1 using a loop (Main.java:15-19).Each value is added to sumaTotal for later average calculation.
2

Read second array values

The program reads 7 integers into array2 using another loop (Main.java:22-26).
Note: There’s a bug in line 25 where it adds array1[i] instead of array2[i] to the sum.
3

Calculate results

After reading all values, the program:
  • Calculates the difference between corresponding elements
  • Computes the average of all values
  • Displays the results

Tips

Entering Values Quickly: You can type a number and press Enter immediately. The program will move to the next prompt automatically.
Testing the Program: Use simple values like 1, 2, 3, 4, 5, 6, 7 for the first array and 0, 0, 0, 0, 0, 0, 0 for the second array to easily verify the output.

Build docs developers (and LLMs) love