Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner in = new Scanner (System.in);
- int capacidade = in.nextInt();
- String texto = "";
- String operacao = "";
- String valores = "";
- String nomes[] = new String[capacidade];
- double tabela[] = new double[capacidade];
- int contdev100 = 0;
- int contsemdev = 0;
- double somadiv = 0;
- double maiordiv = 0;
- int i = 0;
- int z = 0;
- int x = 0;
- int w = 0;
- boolean boo = false;
- for (i = 0; i < capacidade; i++) {
- texto = in.next();
- nomes[i] = texto;
- }
- do {
- texto = in.next();
- if (texto.equals("FIM")) {
- boo = true;
- }
- else {
- for (i = 0; i < capacidade; i++) {
- if (texto.equals(nomes[i])) {
- x = i;
- }
- }
- operacao = in.next();
- if (operacao.equals("C")) {
- valores = in.next();
- tabela[x] -= Double.parseDouble(valores);
- } else {
- valores = in.next();
- tabela[x] += Double.parseDouble(valores);
- }
- x = 0;
- i = 0;
- }
- } while (boo != true);
- int y = 0;
- while(y<capacidade){
- if (tabela[y] > -100.00) {
- contdev100++;
- }
- if (tabela[y] == 0.00) {
- contsemdev++;
- }
- if (tabela[y] < -0.01) {
- somadiv += tabela[y];
- }
- if (tabela[y] < maiordiv) {
- maiordiv = tabela[y];
- w++;
- }
- y++;
- }
- System.out.printf("Contas acima de 100 reais: "+contdev100);
- System.out.printf("%nContas sem dividas: "+contsemdev);
- System.out.printf("%nSoma das dividas: R$ %.2f", Math.abs(somadiv));
- System.out.printf("%nMaior divida: "+nomes [w]+" - R$ "+ Math.abs(maiordiv));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement