fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. Enum Products {
  6. Milk(70),MineralWater(20),Tea(45),Americano(110)
  7.  
  8. int price;
  9. Products(int p) {
  10. price = p;
  11. }
  12.  
  13. int getPrice() {
  14. return price;
  15. }
  16.  
  17.  
  18. }
  19.  
  20. class Demo {
  21. public static void main(String [] args) {
  22. int moneyAmount = 10;
  23. boolean canBuyAnything = false;
  24. for(Product p : Product.values()) {
  25. if(moneyAmount >= p) {
  26. System.out.println("Вы можете купить молоко");
  27. canBuyAnything = true;
  28. }
  29.  
  30. if(moneyAmount >= p) {
  31. System.out.println("Вы можете купить минеральную воду");
  32. canBuyAnything = true;
  33. }
  34.  
  35. if(moneyAmount >= p) {
  36. System.out.println("Вы можете купить чай");
  37. canBuyAnything = true;
  38. }
  39.  
  40. if(moneyAmount >= p) {
  41. System.out.println("Вы можете купить американо");
  42. canBuyAnything = true;
  43. }
  44.  
  45. if(moneyAmount >= p) {
  46. System.out.println("Вы можете купить капучино");
  47. canBuyAnything = true;
  48. }
  49. if(!canBuyAnything) {
  50. System.out.println("Недостаточно средств! Учите джаву и идите работать!");
  51. }
  52. }
  53. }
  54. }
  55.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: class, interface, or enum expected
Enum Products {
^
Main.java:9: error: class, interface, or enum expected
	Products(int p) {
	^
Main.java:11: error: class, interface, or enum expected
	}
	^
Main.java:15: error: class, interface, or enum expected
	}
	^
4 errors
stdout
Standard output is empty