fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println("Coffe-maсhine");
  13.  
  14. int moneyAmount = 20;
  15.  
  16. int[] arOfPrice = new int[5];
  17. String[] arOfName = new String[5];
  18.  
  19. arOfName[0] = "cappucino";
  20. arOfName[1] = "americano";
  21. arOfName[2] = "appleJuice";
  22. arOfName[3] = "milk";
  23. arOfName[4] = "water";
  24.  
  25. arOfPrice[0]=150;
  26. arOfPrice[1]=80;
  27. arOfPrice[2]=70;
  28. arOfPrice[3]=40;
  29. arOfPrice[4]=25;
  30.  
  31. boolean canBuyAnything = false;
  32.  
  33. for(int i = 0; i < arOfPrice.length; ++i ){
  34. if( moneyAmount >= arOfPrice[i]) {
  35. System.out.println("You can buy" + arOfName[i]);
  36. canBuyAnything = true;
  37. }
  38. }
  39.  
  40. if(canBuyAnything == false) {
  41. System.out.println("Недостаточно средств");
  42. }
  43. }
  44. }
Success #stdin #stdout 0.04s 2184192KB
stdin
Standard input is empty
stdout
Coffe-maсhine
Недостаточно средств