Advertisement
Guest User

discode

a guest
Mar 21st, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include "pch.h"
  5. #include <iostream>
  6. #include <fstream>
  7. #include <string>
  8.  
  9.  
  10. using namespace std;
  11.  
  12.  
  13. struct Meaning {
  14. string appleMeaning = "An Apple";
  15. string grapeMeaning = "A Grape";
  16. string mangoMeaning = "A Mango";
  17. string orangeMeaning = "An Orange";
  18.  
  19.  
  20. };
  21. struct Word {
  22. /*
  23. char apple[10] = "apple";
  24. char grape[10] = "grape";
  25. char mango[10] = "mango";
  26. char orange[10] = "orange";
  27. */
  28.  
  29. char apple[10] = "apple";
  30. char grape[10] = "grape";
  31. char mango[10] = "mango";
  32. char orange[10] = "orange";
  33. };
  34.  
  35.  
  36.  
  37. int main() {
  38. Meaning m;
  39. Word w;
  40. string response;
  41.  
  42.  
  43. //char apple[10] = "apple";
  44. /*
  45. switch(response[10]){
  46. case "apple":
  47. cout << m.appleMeaning << endl;
  48. break;
  49.  
  50. case "grape":
  51. cout << m.grapeMeaning << endl;
  52. break;
  53.  
  54. case "mango":
  55. cout << m.mangoMeaning << endl;
  56. break;
  57.  
  58. case "orange":
  59. cout << m.orangeMeaning<< endl;
  60. break;
  61. }
  62. */
  63.  
  64.  
  65.  
  66. for (int i = 0; i < 100; i++) {
  67. cout << "please input a fruit from the list: apple, grape, mango, orange" << endl;
  68. cin >> response;
  69.  
  70. if (response == w.apple)
  71. cout << m.appleMeaning << endl;
  72. else if (response == w.grape)
  73. cout << m.grapeMeaning << endl;
  74. else if (response == w.mango)
  75. cout << m.mangoMeaning << endl;
  76. else if (response == w.orange)
  77. cout << m.orangeMeaning << endl;
  78. else cout << "The fruit you have entered is incorrect! please try again";
  79. }
  80. system("pause");
  81. return 0;
  82. }
  83.  
  84. // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
  85. //
  86.  
  87. #include "pch.h"
  88. #include <iostream>
  89. #include <fstream>
  90. #include <string>
  91.  
  92.  
  93. using namespace std;
  94.  
  95.  
  96. struct Meaning {
  97. string appleMeaning = "An Apple";
  98. string grapeMeaning = "A Grape";
  99. string mangoMeaning = "A Mango";
  100. string orangeMeaning = "An Orange";
  101.  
  102.  
  103. };
  104. struct Word {
  105. /*
  106. char apple[10] = "apple";
  107. char grape[10] = "grape";
  108. char mango[10] = "mango";
  109. char orange[10] = "orange";
  110. */
  111.  
  112. char apple[10] = "apple";
  113. char grape[10] = "grape";
  114. char mango[10] = "mango";
  115. char orange[10] = "orange";
  116. };
  117.  
  118.  
  119.  
  120. int main() {
  121. Meaning m;
  122. Word w;
  123. string response;
  124.  
  125.  
  126. //char apple[10] = "apple";
  127. /*
  128. switch(response[10]){
  129. case "apple":
  130. cout << m.appleMeaning << endl;
  131. break;
  132.  
  133. case "grape":
  134. cout << m.grapeMeaning << endl;
  135. break;
  136.  
  137. case "mango":
  138. cout << m.mangoMeaning << endl;
  139. break;
  140.  
  141. case "orange":
  142. cout << m.orangeMeaning<< endl;
  143. break;
  144. }
  145. */
  146.  
  147.  
  148.  
  149. for (int i = 0; i < 100; i++) {
  150. cout << "please input a fruit from the list: apple, grape, mango, orange" << endl;
  151. cin >> response;
  152.  
  153. if (response == w.apple)
  154. cout << m.appleMeaning << endl;
  155. else if (response == w.grape)
  156. cout << m.grapeMeaning << endl;
  157. else if (response == w.mango)
  158. cout << m.mangoMeaning << endl;
  159. else if (response == w.orange)
  160. cout << m.orangeMeaning << endl;
  161. else cout << "The fruit you have entered is incorrect! please try again";
  162. }
  163. system("pause");
  164. return 0;
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement