Advertisement
l_evandro

uri

May 22nd, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class URI1021{
  4.     public static void main(String args[]){
  5.  
  6.             float valor;
  7.         int qtd100, qtd50, qtd20, qtd10, qtd5, qtd2, qtd1, qtd050, qtd025, qtd010, qtd005, qtd001;
  8.         int resto;
  9.  
  10.         java.util.Scanner teclado = new java.util.Scanner(System.in);
  11.  
  12.         valor = teclado.nextFloat();
  13.  
  14.         float aux = valor - (int)valor;
  15.         int moedas = (int)(aux * 100);
  16.  
  17.         int notas = (int)valor;
  18.  
  19.         qtd100 = notas / 100;
  20.         resto = notas % 100;
  21.  
  22.         qtd50 = resto / 50;
  23.         resto = resto % 50;
  24.  
  25.         qtd20 = resto / 20;
  26.         resto = resto % 20;
  27.  
  28.         qtd10 = resto / 10;
  29.         resto = resto % 10;
  30.  
  31.         qtd5 = resto / 5;
  32.         resto = resto % 5;
  33.  
  34.         qtd2 = resto / 2;
  35.         resto = resto % 2;
  36.  
  37.         //qtd1 = resto / 1;
  38.  
  39.         System.out.println("NOTAS:");
  40.         System.out.println(qtd100 + " nota(s) de R$ 100.00");
  41.         System.out.println(qtd50 + " nota(s) de R$ 50.00");
  42.         System.out.println(qtd20 + " nota(s) de R$ 20.00");
  43.         System.out.println(qtd10 + " nota(s) de R$ 10.00");
  44.         System.out.println(qtd5 + " nota(s) de R$ 5.00");
  45.         System.out.println(qtd2 + " nota(s) de R$ 2.00");
  46.  
  47.         /*qtd1 = moedas / 100;
  48.         System.out.println("moedas" + moedas);*/
  49.  
  50.         System.out.println("Moedas: " + moedas);
  51.         qtd1 = resto / 1;
  52.         resto = moedas % 100;
  53.  
  54.         qtd050 = resto / 50;
  55.         resto = resto % 50;
  56.  
  57.         qtd025 = resto / 25;
  58.         resto = resto % 25;
  59.  
  60.         qtd010 = resto / 10;
  61.         resto = resto % 10;
  62.  
  63.         qtd005 = resto / 5;
  64.         resto = resto % 5;
  65.  
  66.         System.out.println(resto);
  67.  
  68.         qtd001 = resto / 1;
  69.         //resto = resto % 1;
  70.  
  71.         System.out.println("MOEDAS:");
  72.         System.out.println(qtd1 + " moeda(s) de R$ 1.00");
  73.         System.out.println(qtd050 + " moeda(s) de R$ 0.50");
  74.         System.out.println(qtd025 + " moeda(s) de R$ 0.25");
  75.         System.out.println(qtd010 + " moeda(s) de R$ 0.10");
  76.         System.out.println(qtd005 + " moeda(s) de R$ 0.05");
  77.         System.out.println(qtd001 + " moeda(s) de R$ 0.01");
  78.  
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement