TOPIC
Wrong Answer 90%, what is the error?
Daniel172 asked 6 years ago
import java.text.DecimalFormat; import java.util.Scanner;
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int bills[]= {100,50,20,10,5,2,1}; String string= " nota(s) de R$ "; int notas = 0; DecimalFormat df = new DecimalFormat("0.00"); for (int i = 0; i < bills.length; i++) { notas = (int) (n/bills[i]);
System.out.println(notas+string+df.format(bills[i]));
n= (int) (n - (notas*bills[i]));
}
}
}
This topic has not been answered yet. Be the first!