Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.util.Scanner;
  3. /**
  4. * IMPORTANT:
  5. * O nome da classe deve ser "Main" para que a sua solução execute
  6. * Class name must be "Main" for your solution to execute
  7. * El nombre de la clase debe ser "Main" para que su solución ejecutar
  8. */
  9. public class Main {
  10.  
  11. public static void main(String[] args) throws IOException {
  12. Scanner scanner = new Scanner(System.in);
  13. int i =0;
  14. int n = scanner.nextInt();
  15.  
  16. for (i = 0 ;i < n ;i++ ) {
  17.  
  18. int notade100 = n / 100;
  19. int resto100 = (n - notade100*100);
  20. int notade50 = resto100 / 50;
  21. int resto50 = (n - notade100*100 - notade50*50);
  22. int notade20 = resto50 / 20;
  23. int resto20 = (n - notade100*100 - notade50*50 - notade20 *20);
  24. int notade10 = resto20 / 10;
  25. int resto10 = (n - notade100*100 - notade50*50 - notade20 *20 - notade10 *10);
  26. int notade5 = resto10 /5;
  27. int resto5 = (n - notade100*100 - notade50*50 - notade20 *20 - notade10 *10 - notade5 * 5);
  28. int notade2 = resto5 / 2;
  29. int resto2 = (n - notade100*100 - notade50*50 - notade20 *20 - notade10 *10 - notade5 * 5 - notade2 *2);
  30. int notade1 = resto2 / 1;
  31.  
  32. System.out.println(n);
  33. System.out.printf("%d", notade100);
  34. System.out.println(" nota(s) de R$ 100,00");
  35. System.out.printf("%d", notade50);
  36. System.out.println(" nota(s) de R$ 50,00");
  37. System.out.printf("%d", notade20);
  38. System.out.println(" nota(s) de R$ 20,00");
  39. System.out.printf("%d", notade10);
  40. System.out.println(" nota(s) de R$ 10,00");
  41. System.out.printf("%d", notade5);
  42. System.out.println(" nota(s) de R$ 5,00");
  43. System.out.printf("%d", notade2);
  44. System.out.println(" nota(s) de R$ 2,00");
  45. System.out.printf("%d", notade1);
  46. System.out.println(" nota(s) de R$ 1,00");
  47.  
  48. if (n == 0) {
  49.  
  50.  
  51. }
  52. break;
  53. }
  54.  
  55. }
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement