vlatkovski

professional botany

Jul 18th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string getSeedColor();
  6. int getSoilTemperature();
  7. string getSoilState();
  8. string getResult(string seedColor, int temperature, string soilState);
  9.  
  10. int main() {
  11.     string seedColor = getSeedColor();
  12.     int temperature = getSoilTemperature();
  13.     string soilState = getSoilState();
  14.  
  15.     string result = getResult(seedColor, temperature, soilState);
  16.     cout << "The plant you got is: " << result << "\n";
  17. }
  18.  
  19.  
  20. string getSeedColor() {
  21.     string color;
  22.     cout << "What is the seed color?\n";
  23.     getline(cin, color);
  24.     return color;
  25. }
  26.  
  27. int getSoilTemperature() {
  28.     int temp;
  29.     cout << "What is the soil temperature?\n";
  30.     cin >> temp;
  31.     return temp;
  32. }
  33.  
  34. string getSoilState() {
  35.     string state;
  36.     cout << "Is the soil wet or dry?\n";
  37.     cin >> state;
  38.     return state;
  39. }
  40.  
  41. string getResult(string seedColor, int temperature, string soilState) {
  42.     string result;
  43.     if (seedColor == "red") {
  44.         if (temperature > 75) {
  45.             if (soilState == "wet") {result = "sunflower";}
  46.             else if (soilState == "dry") {result = "dandelion";}
  47.         } else {
  48.             result = "mushroom";
  49.         }
  50.     } else if (seedColor == "blue") {
  51.         if (temperature > 60 && temperature < 70) {
  52.             if (soilState == "wet") {result = "dandelion";}
  53.             else if (soilState == "dry") {result = "sunflower";}
  54.         }
  55.     }
  56.     return result;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment