Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- System.out.println("Введите цену товара (руб. и коп.): ");
- Scanner sc = new Scanner(System.in);
- int a = sc.nextInt();
- int b = sc.nextInt();
- System.out.println("Введите, сколько у вас есть денег (руб. и коп.): ");
- int c = sc.nextInt();
- int d = sc.nextInt();
- int e = c - a;
- int f = d - b;
- if (e >= 0 && f >= 0) {
- System.out.printf("Ваша сдача: %d руб. и %d коп. Приходите ещё.", e, f);
- } else if (f <= 0 && e > 0) {
- e = e - 1;
- f = d - b + 100;
- System.out.printf("Ваша сдача: %d руб. и %d коп. Приходите ещё.", e, f);
- } else {
- System.out.println("Вам не хватает денег, приходите, как накопите.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment