Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Y05coins{
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double money = Double.parseDouble(scanner.nextLine());
- double stotinki = money * 100;
- double coins = 0;
- while (stotinki >= 200){
- coins +=1;
- stotinki -= 200;
- }
- while (stotinki >= 100){
- coins +=1;
- stotinki -= 100;
- }
- while (stotinki >= 50){
- coins +=1;
- stotinki -= 50;
- }
- while (stotinki >= 20){
- coins +=1;
- stotinki -= 20;
- }
- while (stotinki >= 10){
- coins +=1;
- stotinki -= 10;
- }
- while (stotinki >= 5){
- coins +=1;
- stotinki -= 5;
- }
- while (stotinki >= 2){
- coins +=1;
- stotinki -= 2;
- }
- coins += stotinki;
- System.out.printf("%.0f",Math.floor(coins));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment