-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestao_08.c
159 lines (125 loc) · 3.11 KB
/
questao_08.c
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <stdio.h>
#include <stdlib.h>
struct despesas {
char nome_responsavel[100];
int numero_apt;
int area;
int numero_moradores;
float valor_mes;
};
int quantidade;
struct despesas apart[40];
void dados();
void ler_dados();
int area_total();
int area_mensalidade(int total);
void apartamento_pessoas();
int main() {
int verdade = 1, opcao, total;
while (verdade == 1) {
printf("\n\nGESTAO DO CONDOMINIO\n\n");
printf(
" 1 - Cadastra dados\n 2 - Ler as instrucoes\n 3 - Area total do "
"condominio\n 4 - Area total por mensalidade\n 5 - Apartamento "
"com mais moradores\n 6 - Sair\n --> ");
scanf("%i", &opcao);
switch (opcao) {
case 1:
dados();
break;
case 2:
ler_dados();
break;
case 3:
total = area_total();
break;
case 4:
//area_mensalidade(total);
break;
case 5:
apartamento_pessoas();
break;
case 6:
printf("\n\nVC FINALIZOU O PROGRAMA\n");
verdade = 0;
break;
default:
printf("\n\nVC DIGITOU VALOR INVALIDO\n\n");
verdade = 0;
break;
}
}
return 0;
}
void dados() {
int i;
printf("\n\nDeseja cadastrar quanto condominos: --> ");
scanf("%i", &quantidade);
setbuf(stdin, NULL);
for (i = 0; i < quantidade; i++) {
printf("VALOR DO I: %i\n", i);
printf("\n MORADOR %i: \n", i + 1);
printf("\n NOME DO RESPONSAVEL: ");
scanf("%[^\n]s", &apart[i].nome_responsavel);
setbuf(stdin, NULL);
printf("\n NUMERO DO APART: ");
scanf(" %i", &apart[i].numero_apt);
setbuf(stdin, NULL);
printf("\n AREA DO APART: ");
scanf("%i", &apart[i].area);
setbuf(stdin, NULL);
printf("\n NUMERO DE MORADORES: ");
scanf(" %i", &apart[i].numero_moradores);
setbuf(stdin, NULL);
printf("\n VALOR POR MES: ");
scanf(" %i", &apart[i].valor_mes);
setbuf(stdin, NULL);
system("clear");
}
}
void ler_dados() {
int i;
for (i = 0; i < quantidade; i++) {
printf("\n\n MORADOR %i: \n", i + 1);
printf(" NOME: %s", apart[i].nome_responsavel);
printf("\n NUMERO: %i", apart[i].numero_apt);
printf("\n AREA: %i", apart[i].area);
printf("\n NUMERO DE MORADORES: %i", apart[i].numero_moradores);
}
system("clear");
}
int area_total() {
int i, total = 0;
for (i = 0; i < quantidade; i++) {
total = total + apart[i].area;
}
system("clear");
printf("\n\n A area total em M2 %i\n\n\n", total);
return total;
}
int area_mensalidade(int total) {
int i;
float despesa, calc, aux;
printf("TOTAL: %i", total);
for (i = 0; i < quantidade; i++) {
printf("\n\n MORADOR %i:\n");
printf("\nDespesa por mes: ");
scanf("%f", despesa);
aux = aux + despesa;
}
calc = aux / total;
system("clear");
printf("Despesa por apartamento: %f\n", calc);
}
void apartamento_pessoas(){
int i, aux, morador;
aux = apart[0].numero_moradores;
for (i = 1; i < quantidade;i++){
if(aux < apart[i].numero_moradores){
aux = apart[i].numero_moradores;
morador = i;
}
}
system("clear");
printf("O morador %s e o que tem mais pessoas com %i", apart[morador].nome_responsavel, aux);
}