Advertisement
VSS2

Untitled

Oct 2nd, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. Scanner in = new Scanner (System.in);
  2. int capacidade = in.nextInt();
  3. String texto = "";
  4. String operacao = "";
  5. String valores = "";
  6. String nomes[] = new String[capacidade];
  7. double tabela[] = new double[capacidade];
  8. int contdev100 = 0;
  9. int contsemdev = 0;
  10. double somadiv = 0;
  11. double maiordiv = 0;
  12. int i = 0;
  13. int z = 0;
  14. int x = 0;
  15. int w = 0;
  16. boolean boo = false;
  17.  
  18. for (i = 0; i < capacidade; i++) {
  19. texto = in.next();
  20. nomes[i] = texto;
  21. }
  22. do {
  23. texto = in.next();
  24. if (texto.equals("FIM")) {
  25. boo = true;
  26. }
  27. else {
  28. for (i = 0; i < capacidade; i++) {
  29. if (texto.equals(nomes[i])) {
  30. x = i;
  31. }
  32. }
  33. operacao = in.next();
  34. if (operacao.equals("C")) {
  35. valores = in.next();
  36. tabela[x] -= Double.parseDouble(valores);
  37. } else {
  38. valores = in.next();
  39. tabela[x] += Double.parseDouble(valores);
  40. }
  41. x = 0;
  42. i = 0;
  43. }
  44. } while (boo != true);
  45.  
  46. int y = 0;
  47. while(y<capacidade){
  48. if (tabela[y] > -100.00) {
  49. contdev100++;
  50. }
  51. if (tabela[y] == 0.00) {
  52. contsemdev++;
  53. }
  54. if (tabela[y] < -0.01) {
  55. somadiv += tabela[y];
  56. }
  57. if (tabela[y] < maiordiv) {
  58. maiordiv = tabela[y];
  59. w++;
  60. }
  61. y++;
  62. }
  63. System.out.printf("Contas acima de 100 reais: "+contdev100);
  64. System.out.printf("%nContas sem dividas: "+contsemdev);
  65. System.out.printf("%nSoma das dividas: R$ %.2f", Math.abs(somadiv));
  66. System.out.printf("%nMaior divida: "+nomes [w]+" - R$ "+ Math.abs(maiordiv));
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement