fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11.  
  12. System.out.println("Coffee Machine:");
  13.  
  14. int moneyAmount = 19;
  15.  
  16. int capuccinoPrice = 120;
  17. int americanoPrice = 80;
  18. int waterPrice = 20;
  19. int milkPrice = 40;
  20.  
  21. boolean canBuyAnything = false;
  22.  
  23. if (moneyAmount >= capuccinoPrice) {
  24. System.out.println("You can buy capuccino");
  25. canBuyAnything = true;
  26. }
  27. if (moneyAmount >= americanoPrice) {
  28. System.out.println("You can buy americano");
  29. canBuyAnything = true;
  30. }
  31. if (moneyAmount >= waterPrice) {
  32. System.out.println("You can buy water");
  33. canBuyAnything = true;
  34. }
  35. if (moneyAmount >= milkPrice) {
  36. System.out.println("You can buy milk");
  37. canBuyAnything = true;
  38. }
  39.  
  40. if (canBuyAnything == false) {
  41. System.out.println("You can not buy anything");
  42. }
  43.  
  44. }
  45. }
Success #stdin #stdout 0.06s 32424KB
stdin
Standard input is empty
stdout
Coffee Machine:
You can not buy anything