Incrementar index de un array
Publicado por Alex (4 intervenciones) el 23/09/2014 22:28:13
Como puedo hacer para que el index del array "pstcq" se vaya incrementando en +1 para que cada vez que el loop se repita muestre la "segunda", "tercera"... y haci sucesivamente dentro del print.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.*;
class j{
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
int numNota = 1;
double nota,notas,prom;
int i = 0;
notas = 0;
String[] pstcq = {"Primera","Segunda","Tercera","Cuarta","Quinta"};
do{
System.out.println("Ingrese la "+pstcq[0]+" Nota");
pstcq[++];
nota = scan.nextDouble();
notas = notas + nota;
numNota = numNota + 1;
}while(numNota <= 5);
prom = notas/5;
System.out.println("El promedio es: "+prom);
}
}
Valora esta pregunta


0