Error en tiempo de ejecucion
Publicado por Johnatan Muza (1 intervención) el 16/03/2016 04:37:13
CLASE INSTANCIABLE:
Alguien me puede ayudar con este codigo? no logro solucionar el error en tiempo de ejecucion :'(
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


0