Skip to content

Instantly share code, notes, and snippets.

@folivetti
Created March 5, 2017 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save folivetti/59405fd2b1293d609b0573c8e9c2a8ee to your computer and use it in GitHub Desktop.
Save folivetti/59405fd2b1293d609b0573c8e9c2a8ee to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int dinheiro, notas;
Scanner leitor = new Scanner(System.in);
dinheiro = leitor.nextInt();
notas = dinheiro/100;
if (notas != 0) {
System.out.println(notas + " de cem");
}
dinheiro = dinheiro - notas*100;
notas = dinheiro/50;
if (notas != 0) {
System.out.println(notas + " de cinquenta");
}
dinheiro = dinheiro - notas*50;
notas = dinheiro/20;
if (notas != 0) {
System.out.println(notas + " de vinte");
}
dinheiro = dinheiro - notas*20;
notas = dinheiro/10;
if (notas != 0) {
System.out.println(notas + " de dez");
}
dinheiro = dinheiro - notas*10;
notas = dinheiro/5;
if (notas != 0) {
System.out.println(notas + " de cinco");
}
dinheiro = dinheiro - notas*5;
notas = dinheiro/2;
if (notas != 0) {
System.out.println(notas + " de dois");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment