Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class rabotavklas {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- System.out.println("INPUT SUM :");
- int sum = scan.nextInt();
- CountNominees(sum);
- } // end of main function
- public static void CountNominees (int sum)
- {
- int counter = 0;
- int index = 0;
- int [] nominees = {30,20,5};
- while(sum > 0 )
- {
- if(sum >= nominees[index])
- {
- sum = sum - nominees[index];
- counter++;
- System.out.println(sum + nominees[index] + "(-" + nominees[index] + ") COUNTER IS :" + counter);
- }
- else
- {
- if(index + 1 < nominees.length)
- {
- index++;
- }
- else
- {
- System.out.println("NO MORE NOMINEES FOR THIS SUM : " + sum);
- break;
- }
- }
- }// end of while
- System.out.println();
- System.out.println("NUMBER OF NOMINEES IS :" + counter);
- } // end of class
- }
Advertisement
Add Comment
Please, Sign In to add comment