fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5. char drink[20];
  6. int price = 0;
  7.  
  8. // Display menu
  9. printf("Drink Menu:\n");
  10. printf("1. Green Tea - 50\n");
  11. printf("2. Thai Tea - 50\n");
  12. printf("3. Peach Tea - 45\n");
  13. printf("4. Matcha Latte - 55\n");
  14. printf("5. Americano - 60\n");
  15. printf("6. Latte - 60\n");
  16.  
  17. // Get user input
  18. printf("Enter your drink name: ");
  19. scanf("%s", drink);
  20.  
  21. // Determine price based on drink name
  22. if (strcmp(drink, "GreenTea") == 0 || strcmp(drink, "green tea") == 0) {
  23. price = 50;
  24. } else if (strcmp(drink, "ThaiTea") == 0 || strcmp(drink, "thai tea") == 0) {
  25. price = 50;
  26. } else if (strcmp(drink, "PeachTea") == 0 || strcmp(drink, "peach tea") == 0) {
  27. price = 45;
  28. } else if (strcmp(drink, "MatchaLatte") == 0 || strcmp(drink, "matcha latte") == 0) {
  29. price = 55;
  30. } else if (strcmp(drink, "Americano") == 0 || strcmp(drink, "americano") == 0) {
  31. price = 60;
  32. } else if (strcmp(drink, "Latte") == 0 || strcmp(drink, "latte") == 0) {
  33. price = 60;
  34. } else {
  35. printf("Drink not found!\n");
  36. return 1;
  37. }
  38.  
  39. // Display price
  40. printf("The price of %s is %d baht.\n", drink, price);
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0.03s 25340KB
stdin
Standard input is empty
stdout
#include <stdio.h>
#include <string.h>

int main() {
    char drink[20];
    int price = 0;

    // Display menu
    printf("Drink Menu:\n");
    printf("1. Green Tea - 50\n");
    printf("2. Thai Tea - 50\n");
    printf("3. Peach Tea - 45\n");
    printf("4. Matcha Latte - 55\n");
    printf("5. Americano - 60\n");
    printf("6. Latte - 60\n");

    // Get user input
    printf("Enter your drink name: ");
    scanf("%s", drink);

    // Determine price based on drink name
    if (strcmp(drink, "GreenTea") == 0 || strcmp(drink, "green tea") == 0) {
        price = 50;
    } else if (strcmp(drink, "ThaiTea") == 0 || strcmp(drink, "thai tea") == 0) {
        price = 50;
    } else if (strcmp(drink, "PeachTea") == 0 || strcmp(drink, "peach tea") == 0) {
        price = 45;
    } else if (strcmp(drink, "MatchaLatte") == 0 || strcmp(drink, "matcha latte") == 0) {
        price = 55;
    } else if (strcmp(drink, "Americano") == 0 || strcmp(drink, "americano") == 0) {
        price = 60;
    } else if (strcmp(drink, "Latte") == 0 || strcmp(drink, "latte") == 0) {
        price = 60;
    } else {
        printf("Drink not found!\n");
        return 1;
    }

    // Display price
    printf("The price of %s is %d baht.\n", drink, price);

    return 0;
}