Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.8 kB
1
Indexable
Never
public class Zad3 {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        System.out.println("Podaj kwote");
        double kwota = sc.nextDouble();

        int piec = 0;
        int dwa=0;
        int jeden=0;
        int piecdziesiat_gr=0;
        int dwadziescia_gr=0;
        int dziesiec_gr=0;
        int piec_gr=0;
        int dwa_gr=0;
        int jeden_gr=0;

        System.out.println("Kwota: " + kwota);


        while (kwota >= 5 ) {
            kwota -= 5;
            piec++;
        }
        while (kwota >= 2 ) {
            kwota -= 2;
            dwa++;
        }
        while (kwota >= 1 ) {
            kwota -= 1;
            jeden++;
        }
        while (kwota >= 0.5 ) {
            kwota -= 0.5;
            piecdziesiat_gr++;
        }
        while (kwota >= 0.2 ) {
            kwota -= 0.2;
            dwadziescia_gr++;
        }
        while (kwota >= 0.1 ) {
            kwota -= 0.1;
            dziesiec_gr++;
        }
        while (kwota >= 0.05 ) {
            kwota -= 0.5;
            piec_gr++;
        }
        while (kwota >= 0.02 ) {
            kwota -= 0.02;
            dwa_gr++;
        }
        while (kwota >= 0.01 ) {
            kwota -= 0.01;
            jeden_gr++;
        }


        System.out.println("5zl: " + piec);
        System.out.println("2zl: " + dwa);
        System.out.println("1zl: " + jeden);
        System.out.println("50gr: " + piecdziesiat_gr);
        System.out.println("20gr: " + dwadziescia_gr);
        System.out.println("10gr: " + dziesiec_gr);
        System.out.println("5gr: " + piec_gr);
        System.out.println("2gr: " + dwa_gr);
        System.out.println("1gr: " + jeden_gr);

    }
}