Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Projects.homework;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- double price = Double.parseDouble(sc.nextLine());
- double paid = Double.parseDouble(sc.nextLine());
- double returnMoney = Math.round((paid - price) * 100);
- // System.out.println(returnMoney);
- int lev = (int) returnMoney / 100;
- // System.out.println(lev);
- int tenthStotinki = (int) returnMoney % 100;
- // System.out.println(tenthStotinki);
- int stotinki = (int) returnMoney % 10;
- // System.out.println(stotinki);
- if (lev > 0) {
- System.out.printf("%d x 1 lev", lev);
- }
- if (tenthStotinki > 0) {
- if (tenthStotinki >= 50) {
- System.out.printf("%n1 x 50 stotinki");
- tenthStotinki -= 50;
- }
- if (tenthStotinki >= 40 && tenthStotinki <= 49) {
- System.out.printf("%n2 x 20 stotinki");
- }
- if (tenthStotinki >= 20 && tenthStotinki <= 39) {
- System.out.printf("%n1 x 20 stotinki");
- }
- if (tenthStotinki == 10 || tenthStotinki == 30) {
- System.out.printf("%n1 x 10 stotinki");
- }
- if (stotinki > 0) {
- if (stotinki >= 5) {
- System.out.printf("%n1 x 5 stotinki");
- }
- if (stotinki == 9 || stotinki == 4) {
- System.out.printf("%n2 x 2 stotinki");
- }
- if (stotinki == 2 || stotinki == 7 || stotinki == 8) {
- System.out.printf("%n1 x 2 stotinki");
- }
- if (stotinki == 1 || stotinki == 3 || stotinki == 6 || stotinki == 8) {
- System.out.printf("%n1 x 1 stotinka");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement