Advertisement
silasvasconcelos

Quantidade de Cédulas a partir de um valor

Jan 9th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. $valor = 1588;
  4.  
  5. $notas_100 = intval($valor / 100);
  6. $mod_100 = ($valor % 100);
  7.  
  8. $notas_50 = intval($mod_100 / 50);
  9. $mod_50 = ($mod_100 % 50);
  10.  
  11. $notas_20 = intval($mod_50 / 20);
  12. $mod_20 = ($mod_50 % 20);
  13.  
  14. $notas_10 = intval($mod_20 / 10);
  15. $mod_10 = ($mod_20 % 10);
  16.  
  17. $notas_5 = intval($mod_10 / 5);
  18. $mod_5 = ($mod_10 % 5);
  19.  
  20. $notas_2 = intval($mod_5 / 2);
  21. $mod_2 = ($mod_5 % 2);
  22.  
  23. $notas_1 = intval($mod_2 / 1);
  24. $mod_1 = ($mod_2 % 1);
  25.  
  26. echo 'Valor: R$' . number_format($valor, 2, ',','.');
  27. echo "\n";
  28. echo 'Notas de 100: ' . $notas_100;
  29. echo "\n";
  30. echo 'Notas de 50: ' . $notas_50;
  31. echo "\n";
  32. echo 'Notas de 20: ' . $notas_20;
  33. echo "\n";
  34. echo 'Notas de 10: ' . $notas_10;
  35. echo "\n";
  36. echo 'Notas de 5: ' . $notas_5;
  37. echo "\n";
  38. echo 'Notas de 2: ' . $notas_2;
  39. echo "\n";
  40. echo 'Notas ou moedas de 1: ' . $notas_1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement