-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
85 lines (66 loc) · 1.52 KB
/
main.cpp
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
#include <iostream>
using namespace std;
int main()
{
int valorMax = 0;
char valores[11];
int suma = 0;
float valorProcesado = 0;
string total = "";
cout<<"Ingresa el numero maximo de valores (Max '10'):";
cin>>valorMax;
if(valorMax > 10)
{
cout<<"[Error] El numero es superior a 10";
return 0;
}
for(int n = 0;n < valorMax;n ++)
{
cout<<"Ingresa el valor (S,A,B,C,D):";
cin>>valores[n];
switch(valores[n])
{
case 'S':
suma = suma + 1;
break;
case 'A':
suma = suma + 2;
break;
case 'B':
suma = suma + 3;
break;
case 'C':
suma = suma + 4;
break;
case 'D':
suma = suma + 5;
break;
default:
cout<<"Error de valor"<<endl;
break;
}
}
valorProcesado = suma/valorMax;
if(valorProcesado >= 0 && valorProcesado < 0.2f)
{
total = "S";
}
if(valorProcesado >= 0.2f && valorProcesado < 0.4f)
{
total = "A";
}
if(valorProcesado >= 0.4f && valorProcesado < 0.6f)
{
total = "B";
}
if(valorProcesado >= 0.6f && valorProcesado < 0.8f)
{
total = "C";
}
if(valorProcesado >= 0.8f && valorProcesado <= 1.0f)
{
total = "D";
}
cout<<"El valor es: "<<total<<endl;
return 0;
}