MilaDimitrovaa

Работа в клас - Мила Йонкова 18317

Nov 6th, 2020
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class rabotavklas {
  4.  
  5.     public static void main(String[] args)
  6.     {
  7.     Scanner scan = new Scanner(System.in);
  8.     System.out.println("INPUT SUM :");
  9.      int sum = scan.nextInt();
  10.      
  11.      CountNominees(sum);
  12.        
  13.     } // end of main function
  14.  
  15.         public static void CountNominees (int sum)
  16.         {
  17.             int counter = 0;
  18.             int index = 0;
  19.             int [] nominees = {30,20,5};
  20.        
  21.         while(sum > 0 )
  22.         {
  23.            if(sum >= nominees[index])
  24.            {
  25.             sum = sum - nominees[index];
  26.             counter++;
  27.             System.out.println(sum + nominees[index] + "(-" + nominees[index] + ") COUNTER IS :" + counter);
  28.         }
  29.            else
  30.            {
  31.                if(index + 1 < nominees.length)
  32.                {
  33.            index++;
  34.            }
  35.                else
  36.            {
  37.                    System.out.println("NO MORE NOMINEES FOR THIS SUM : " + sum);
  38.                    break;
  39.            }
  40.          }
  41.         }// end of while
  42.        
  43.         System.out.println();
  44.         System.out.println("NUMBER OF NOMINEES IS :" + counter);
  45.        
  46.        
  47.        
  48.        
  49.        
  50.        
  51.        
  52.     } // end of class
  53.  
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment