
Help mi; contador que no cuenta
Publicado por Carlos (1 intervención) el 16/07/2015 03:49:36
Mi problema se encuentra al tratar de incrementar el contador de aprobados y desaprobados, este debería trabajar contando solo por condición booleana sobre la condicional que establece si es V o F, luego debería guardar e imprimir las cantidades exactas de alumnos desaprobados y aprobados, pero no sucede porque empieza desde 0 y luego al encontrar otro aprobado vuelve a retomar el valor desde 0 y no calcula el total, en pocas palabras no se incrementa si se interrumpe el contador.
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Registros
{
class Alumnos
{
string[] nombre = new string[3];
int[] nota = new int[3];
int notaCap = 0;
int acMa = 0;
int cantd = 0, desa = 0, apro = 0;
float prom;
int x;
/* ~~~~~~~~~~~~~~ METODO INICIALIZAR ~~~~~~~~~~~~~~~ */
public void inicializar()
{
//ingresando para tener cantidad mas limitada por condicion
/* int x = 0;
do
{
Console.Write(x);
x++;
} while (0 > 3);
//fin de Do while.*/
for (int i = 0; i < nombre.Length; i++)
{
Console.WriteLine("Nombre: " + (i + 1));
nombre[i] = Console.ReadLine();
//Validamos nota.
while (!int.TryParse(Console.ReadLine(), out notaCap))
Console.WriteLine("Nota: " + nombre[i]);
nota[i] = notaCap;
//sumamos valores acma acumulador
acMa = acMa + notaCap;
//contador de veces de ingreso de datos
cantd = (i + 1);
//limpiamos
Console.Clear();
}
Console.WriteLine("Los Mejores Alumnos son: ");
// Imprimir notas mayores --> i=nota
}
/* ~~~~~~~~~~~~~~ METODO EDADES ~~~~~~~~~~~~~~~ */
public void edades()
{
for (int j = 0; j < nombre.Length; j++)
{
//cantd = Convert.ToInt16(j + 1);
if (nota[j] > 8.0)
{
Console.WriteLine(nombre[j] + " Aprobado " + nota[j] + " puntos " + " apro: " + apro);
apro = (j + 1);
}
else
{
Console.WriteLine(nombre[j] + " Desaprobado " + nota[j] + " puntos " + " desa: " + desa);
desa = (j + 1);
}
}
prom = acMa / cantd;
}
/* ~~~~~~~~~~~~~~ METODO IMPRIMIR ~~~~~~~~~~~~~~~ */
public void imprimir()
{
Console.WriteLine();
Console.WriteLine("promedio: " + prom + " hay " + desa + " Cantidad de desaprobados y " + apro + " Cantidad de aprobados");
Console.WriteLine();
Console.WriteLine(" acma: " + acMa + " notaCap: " + notaCap + " cantd: " + cantd);
Console.ReadKey();
}
}
}
para luego llamar a:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Registros
{
class Program
{
static void Main(string[] args)
{
Alumnos infoAlu = new Alumnos();
infoAlu.inicializar();
infoAlu.edades();
infoAlu.imprimir();
}
}
}
- Registros2.rar(57,1 KB)
Valora esta pregunta


0