Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string getSeedColor();
- int getSoilTemperature();
- string getSoilState();
- string getResult(string seedColor, int temperature, string soilState);
- int main() {
- string seedColor = getSeedColor();
- int temperature = getSoilTemperature();
- string soilState = getSoilState();
- string result = getResult(seedColor, temperature, soilState);
- cout << "The plant you got is: " << result << "\n";
- }
- string getSeedColor() {
- string color;
- cout << "What is the seed color?\n";
- getline(cin, color);
- return color;
- }
- int getSoilTemperature() {
- int temp;
- cout << "What is the soil temperature?\n";
- cin >> temp;
- return temp;
- }
- string getSoilState() {
- string state;
- cout << "Is the soil wet or dry?\n";
- cin >> state;
- return state;
- }
- string getResult(string seedColor, int temperature, string soilState) {
- string result;
- if (seedColor == "red") {
- if (temperature > 75) {
- if (soilState == "wet") {result = "sunflower";}
- else if (soilState == "dry") {result = "dandelion";}
- } else {
- result = "mushroom";
- }
- } else if (seedColor == "blue") {
- if (temperature > 60 && temperature < 70) {
- if (soilState == "wet") {result = "dandelion";}
- else if (soilState == "dry") {result = "sunflower";}
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment