Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct Meaning {
- string appleMeaning = "An Apple";
- string grapeMeaning = "A Grape";
- string mangoMeaning = "A Mango";
- string orangeMeaning = "An Orange";
- };
- struct Word {
- /*
- char apple[10] = "apple";
- char grape[10] = "grape";
- char mango[10] = "mango";
- char orange[10] = "orange";
- */
- char apple[10] = "apple";
- char grape[10] = "grape";
- char mango[10] = "mango";
- char orange[10] = "orange";
- };
- int main() {
- Meaning m;
- Word w;
- string response;
- //char apple[10] = "apple";
- /*
- switch(response[10]){
- case "apple":
- cout << m.appleMeaning << endl;
- break;
- case "grape":
- cout << m.grapeMeaning << endl;
- break;
- case "mango":
- cout << m.mangoMeaning << endl;
- break;
- case "orange":
- cout << m.orangeMeaning<< endl;
- break;
- }
- */
- for (int i = 0; i < 100; i++) {
- cout << "please input a fruit from the list: apple, grape, mango, orange" << endl;
- cin >> response;
- if (response == w.apple)
- cout << m.appleMeaning << endl;
- else if (response == w.grape)
- cout << m.grapeMeaning << endl;
- else if (response == w.mango)
- cout << m.mangoMeaning << endl;
- else if (response == w.orange)
- cout << m.orangeMeaning << endl;
- else cout << "The fruit you have entered is incorrect! please try again";
- }
- system("pause");
- return 0;
- }
- // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- struct Meaning {
- string appleMeaning = "An Apple";
- string grapeMeaning = "A Grape";
- string mangoMeaning = "A Mango";
- string orangeMeaning = "An Orange";
- };
- struct Word {
- /*
- char apple[10] = "apple";
- char grape[10] = "grape";
- char mango[10] = "mango";
- char orange[10] = "orange";
- */
- char apple[10] = "apple";
- char grape[10] = "grape";
- char mango[10] = "mango";
- char orange[10] = "orange";
- };
- int main() {
- Meaning m;
- Word w;
- string response;
- //char apple[10] = "apple";
- /*
- switch(response[10]){
- case "apple":
- cout << m.appleMeaning << endl;
- break;
- case "grape":
- cout << m.grapeMeaning << endl;
- break;
- case "mango":
- cout << m.mangoMeaning << endl;
- break;
- case "orange":
- cout << m.orangeMeaning<< endl;
- break;
- }
- */
- for (int i = 0; i < 100; i++) {
- cout << "please input a fruit from the list: apple, grape, mango, orange" << endl;
- cin >> response;
- if (response == w.apple)
- cout << m.appleMeaning << endl;
- else if (response == w.grape)
- cout << m.grapeMeaning << endl;
- else if (response == w.mango)
- cout << m.mangoMeaning << endl;
- else if (response == w.orange)
- cout << m.orangeMeaning << endl;
- else cout << "The fruit you have entered is incorrect! please try again";
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement