Im having trouble with my program I wrote it using tree nodes but found out that im only sapose to use if else and while loop dont remember how to use the old stuff any ideas?
This program takes inputs from the user to classify an animal as one of Insect, Reptile, Bird and Mammal. The program should first ask a yes or no question and starting classification between Vertebrate and Invertebrate. If the user’s input (Y/N) indicates that the animal is Invertebrate then we classify the animal as an Insect and stop asking more questions.If it is Vertebrate, we print second question out and ask for another input from the user to choose from Cold-blooded and Warm-blooded animals. If it is Cold-blooded, we classify the animal as Reptile and stop the program. Otherwise we continue to the next question and classify the animal as Bird or Mammal.The program should take both lower case and upper case letter from the user, and run repeatedly if the user wants to start over.
I'm having trouble on how to even begin to write it.
Here's and example he gave:
Animal Classifier
Does the animal have backbones (Y/N)? y
The animal is a Vertebrate. Let's continue...
Does the animal's body feel cold (Y/N)? N
The animal is Warm-blooded. Let's continue...
Can it fly (Y/N)? Y
The animal is a Bird.
Do you want to start over (Y/N)? y
Animal Classifier
Does the animal have backbones (Y/N)? Y
The animal is a Vertebrate. Let's continue...
Does the animal's body feel cold (Y/N)? y
The animal is a Reptile.
Do you want to start over (Y/N)? n
Press any key to continue . .
my code works but i have to rewrite it some how to make it simpler
#include <iostream>
#include <string>
#include <sstream>
head = newTreeNode(string("Does the animal have a backbone? "));
head->no = newTreeNode(string("Insect."));
head->yes = newTreeNode(string("Does it have cold blood? "));
p = head->yes;
p->yes = newTreeNode(string("Reptile."));
p->no = newTreeNode(string("Can it fly? "));
p = p->no;
p->yes = newTreeNode(string("Bird."));
p->no = newTreeNode(string("Mammal."));