Java - Error en tiempo de ejecucion

 
Vista:

Error en tiempo de ejecucion

Publicado por Johnatan Muza (1 intervención) el 16/03/2016 04:37:13
CLASE INSTANCIABLE:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import java.util.Scanner;
public class Array_Of_Int_1
{//START CLASS
 
	Scanner input = new Scanner (System.in); // READ FROM THE KEYBOARD
		//FIELS:
		public int array[];
		public int number;
		public int length;
		public String st ="";
 
		//CONSTRUCTOR:
		public Array_Of_Int_1 ()
		{
 
		}
		//POPULATE ARRAY METHOD:
 
		public int Populate_Array (int array[])
		{//START POPULATE ARRAY
            System.out.println("How much numbers do you want to add?");
            length = input.nextInt();
            array = new int[length];
            int value = 0;
            for(int ind = 0; ind < array.length;ind++)
            {//START FOR
            	System.out.println("What is the " +(ind+1)+ "º value?");
                value =input.nextInt();
                if(value >= 0)
                {//START IF
                	array[ind] = value;
                    number = ind + 1;
                    st+= number + ".- "+array[ind] + "\n";
                }//FINISH IF
                else
                {//START ELSE
                	break;
                }//FINISH ELSE
            }//FINISH FOR
            return number;
		}//FINISH POPULATE ARRAY
		//STRING METHOD:
		public String List ()
		{//START LIST
			return st;
		}//FINISH LIST
		//ADD INTEGERS METHOD:
		public int Add_Integers (int array[], int number)
		{//START ADD INTEGERS
            int sum = 0;
            for(int ind2 =0; ind2 < number; ind2++)
            {//START FOR
            	sum += array[ind2];
            }//FINISH FOR
            return sum;
		}//FINISH ADD INTEGERS
		//BIGGEST METHOD
		public int Biggest (int array[], int number)
		{//START BIGGEST
            int biggest =0;
            for(int ind3=0;ind3 < number;ind3++)
            {//START FOR
                    if(array[ind3] > biggest)
                    {//START IF
                            biggest = array[ind3];
                    }//FINISH IF
 
            }//FINISH FOR
            return biggest;
		}//FINISH BIGGEST
 
}//FINISH CLASS
 
/code]
 
 
 
 
CLASE PRINCIPAL:
 
[code]
import java.util.Scanner;
public class Use_Array_Of_int_1 {//START CLASS
 
	public static void main(String[] args) {//START MAIN
		Array_Of_Int_1 aoi = new Array_Of_Int_1 ();
		int array[] = new int[0];
		int number = aoi.Populate_Array(array);
		String st = aoi.List();
		int sum = aoi.Add_Integers(array, number);
		System.out.println("\n"+ number + " numbers have been added. \n");
		System.out.println("The numbers were: \n");
		System.out.println("-----------------------------------------------------------------");
		System.out.println(st);
		System.out.println("-----------------------------------------------------------------");
		System.out.println("\n The sum of the numbers was: \n");
		System.out.println(sum);
 
 
	}//FINISH MAIN
 
}//FINISH CLASS

Alguien me puede ayudar con este codigo? no logro solucionar el error en tiempo de ejecucion :'(
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 144
Ha mantenido su posición en Java (en relación al último mes)
Gráfica de Java

Error en tiempo de ejecucion

Publicado por Thanatos (97 intervenciones) el 16/03/2016 08:43:45

Clase Instanciable



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
 
public class ArrayOfInt1 {
    public int array[];
    public int number;
    public String st = "";
 
    public void populateArray() {
        Scanner input = new Scanner(System.in);
 
        System.out.print("How much numbers do you want to add?\nquantity = ");
        int length = input.nextInt();
        array = new int[length];
 
        System.out.println();
 
        int value = 0;
        for (int ind = 0; ind < array.length; ++ind) {
            System.out.print("What is the " + (ind + 1) + "º value? ");
            value = input.nextInt();
            if (value >= 0) {
                array[ind] = value;
                ++number;
                st += number + ".- " + array[ind] + "\n";
            } else {
                break;
            }
        }
        input.close();
    }
 
    public int addIntegers() {
        int sum = 0;
        for (int ind = 0; ind < number; ++ind) {
            sum += array[ind];
        }
        return sum;
    }
 
    public int biggest() {
        int biggie = 0;
        for (int ind = 0; ind < number; ++ind) {
            if (array[ind] > biggie) {
                biggie = array[ind];
            }
        }
        return biggie;
    }
 
    public int getNumber() {
        return number;
    }
 
    @Override
    public String toString() {
        return st;
    }
}


Clase Principal



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class UseArrayOfInt1 {
 
    public static void main(String[] args) {
        ArrayOfInt1 aoi = new ArrayOfInt1();
        aoi.populateArray();
 
        System.out.println(
            "\n" + aoi.getNumber() + " numbers have been added.\n\n"
            + "The numbers were:\n"
            + "--------------------------------------------------------------\n"
            + aoi
            + "--------------------------------------------------------------\n"
            + "\nThe sum of the numbers was: " + aoi.addIntegers() + "\n"
            + "\nThe biggest number was: " + aoi.biggest()
        );
    }
 
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar