Advertisement
Guest User

Untitled

a guest
Feb 8th, 2022
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. package Projects.homework;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. Scanner sc = new Scanner(System.in);
  10. double price = Double.parseDouble(sc.nextLine());
  11. double paid = Double.parseDouble(sc.nextLine());
  12.  
  13. double returnMoney = Math.round((paid - price) * 100);
  14. // System.out.println(returnMoney);
  15.  
  16. int lev = (int) returnMoney / 100;
  17. // System.out.println(lev);
  18. int tenthStotinki = (int) returnMoney % 100;
  19. // System.out.println(tenthStotinki);
  20. int stotinki = (int) returnMoney % 10;
  21. // System.out.println(stotinki);
  22.  
  23. if (lev > 0) {
  24. System.out.printf("%d x 1 lev", lev);
  25. }
  26. if (tenthStotinki > 0) {
  27. if (tenthStotinki >= 50) {
  28. System.out.printf("%n1 x 50 stotinki");
  29. tenthStotinki -= 50;
  30. }
  31. if (tenthStotinki >= 40 && tenthStotinki <= 49) {
  32. System.out.printf("%n2 x 20 stotinki");
  33. }
  34. if (tenthStotinki >= 20 && tenthStotinki <= 39) {
  35. System.out.printf("%n1 x 20 stotinki");
  36. }
  37. if (tenthStotinki == 10 || tenthStotinki == 30) {
  38. System.out.printf("%n1 x 10 stotinki");
  39. }
  40. if (stotinki > 0) {
  41. if (stotinki >= 5) {
  42. System.out.printf("%n1 x 5 stotinki");
  43. }
  44. if (stotinki == 9 || stotinki == 4) {
  45. System.out.printf("%n2 x 2 stotinki");
  46. }
  47. if (stotinki == 2 || stotinki == 7 || stotinki == 8) {
  48. System.out.printf("%n1 x 2 stotinki");
  49. }
  50. if (stotinki == 1 || stotinki == 3 || stotinki == 6 || stotinki == 8) {
  51. System.out.printf("%n1 x 1 stotinka");
  52. }
  53.  
  54. }
  55. }
  56. }
  57. }
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement