galinyotsev123

ProgBasics05while-Loop-Y05coins

Jan 7th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Y05coins{
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double money = Double.parseDouble(scanner.nextLine());
  8. double stotinki = money * 100;
  9. double coins = 0;
  10.  
  11. while (stotinki >= 200){
  12. coins +=1;
  13. stotinki -= 200;
  14. }
  15. while (stotinki >= 100){
  16. coins +=1;
  17. stotinki -= 100;
  18. }
  19. while (stotinki >= 50){
  20. coins +=1;
  21. stotinki -= 50;
  22. }
  23. while (stotinki >= 20){
  24. coins +=1;
  25. stotinki -= 20;
  26. }
  27. while (stotinki >= 10){
  28. coins +=1;
  29. stotinki -= 10;
  30. }
  31. while (stotinki >= 5){
  32. coins +=1;
  33. stotinki -= 5;
  34. }
  35. while (stotinki >= 2){
  36. coins +=1;
  37. stotinki -= 2;
  38. }
  39. coins += stotinki;
  40.  
  41. System.out.printf("%.0f",Math.floor(coins));
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment