fork(1) download
  1. #include <stdio.h>
  2.  
  3. /* Patrick Andrade */
  4. /* Final Question 1 */
  5. struct date { int month; int date; int year; };
  6.  
  7. struct producer {
  8. char name[100];
  9. char city[50];
  10. char state[50];
  11. char country[50];
  12. };
  13.  
  14. struct volume {
  15. float amount;
  16. char unit[10];
  17. };
  18.  
  19. struct priceInfo {
  20. float price;
  21. char currency[10];
  22. };
  23.  
  24. /* Base structures */
  25. struct Beer {
  26. int stockID;
  27. struct date bornOnDate;
  28. char type[70];
  29. char brand[100];
  30. float abv;
  31. struct producer brewery;
  32. struct volume container;
  33. struct priceInfo pricing;
  34. int ibu;
  35. int calories;
  36. int stockQuantity;
  37. int shelfLifeMonths;
  38. int isCraft;
  39. };
  40.  
  41. struct Wine {
  42. int stockID;
  43. char varietal[70];
  44. char brand[100];
  45. int vintage;
  46. float abv;
  47. char region[70];
  48. struct producer winery;
  49. struct volume container;
  50. struct priceInfo pricing;
  51. char sweetness[20];
  52. int agingMonths;
  53. int stockQuantity;
  54. int isSparkling;
  55. };
  56.  
  57. struct Spirits {
  58. int stockID;
  59. char type[50];
  60. char brand[100];
  61. int age;
  62. float abv;
  63. struct producer distillery;
  64. struct volume container;
  65. struct priceInfo pricing;
  66. char barrelType[50];
  67. int proof;
  68. int stockQuantity;
  69. int isImported;
  70. };
  71.  
  72. /* Test main function */
  73. int main(void) {
  74. /* Beer - Budweiser */
  75. struct Beer myBeer = {
  76. 1001, {8, 10, 2025}, "American Lager", "Budweiser", 5.0,
  77. {"Anheuser-Busch", "St. Louis", "Missouri", "USA"},
  78. {12.0, "oz"}, {1.99, "USD"}, 12, 145, 500, 6, 0
  79. };
  80.  
  81. /* Wine - Beringer */
  82. struct Wine myWine = {
  83. 2001, "Cabernet Sauvignon", "Beringer", 2020, 14.5,
  84. "Napa Valley",
  85. {"Beringer Vineyards", "St. Helena", "California", "USA"},
  86. {750.0, "ml"}, {24.99, "USD"}, "Dry", 18, 120, 0
  87. };
  88.  
  89. /* Spirits - Scotch */
  90. struct Spirits mySpirit = {
  91. 3001, "Scotch Whisky", "Johnnie Walker", 12, 40.0,
  92. {"Johnnie Walker Distillery", "Kilmarnock", "Ayrshire", "Scotland"},
  93. {750.0, "ml"}, {45.00, "USD"}, "Oak", 80, 80, 1
  94. };
  95.  
  96. /* Output */
  97. printf("Beer:\n Brand: %s\n Type: %s\n ABV: %.1f%%\n Price: %.2f %s\n\n",
  98. myBeer.brand, myBeer.type, myBeer.abv,
  99. myBeer.pricing.price, myBeer.pricing.currency);
  100.  
  101. printf("Wine:\n Brand: %s\n Varietal: %s\n ABV: %.1f%%\n Price: %.2f %s\n\n",
  102. myWine.brand, myWine.varietal, myWine.abv,
  103. myWine.pricing.price, myWine.pricing.currency);
  104.  
  105. printf("Spirit:\n Brand: %s\n Type: %s\n ABV: %.1f%%\n Price: %.2f %s\n",
  106. mySpirit.brand, mySpirit.type, mySpirit.abv,
  107. mySpirit.pricing.price, mySpirit.pricing.currency);
  108.  
  109. return 0;
  110. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Beer:
 Brand: Budweiser
 Type: American Lager
 ABV: 5.0%
 Price: 1.99 USD

Wine:
 Brand: Beringer
 Varietal: Cabernet Sauvignon
 ABV: 14.5%
 Price: 24.99 USD

Spirit:
 Brand: Johnnie Walker
 Type: Scotch Whisky
 ABV: 40.0%
 Price: 45.00 USD