Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- //point 1
- System.out.println("МОЛЯ ВЪВЕДЕТЕ СЪМАТА :");
- int sum = input.nextInt();
- CountNominees(sum);
- }
- //end of main
- public static void CountNominees(int sum) {
- int counter = 0;//брояч за монетите
- int index = 0;//индекс за масива с номинали
- int[] nominees = {50, 20, 10, 5, 2, 1};//масив с номинали
- while (sum > 0) {
- if (sum / nominees[index] > 0) {
- sum = sum - nominees[index];
- counter++;
- System.out.println(sum + nominees[index] + "(-" + nominees[index] + " )[БРОЯЧ: " + counter + "]");
- } else
- index++;//преминаване на следващия номинал от масива с номинали
- System.out.println();
- }
- System.out.println("БРОЯТ НА МОНЕТИТЕ Е:" + counter);
- }
- }//end of class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement