Hey guys I’m working on the Dog years project and wanted to fiddle with getting user inputs. what follows is my code and the link there after. Problem is I can’t get the math to work right. when I look at the answers section my formula matches but I get some really strange results. any help would be appreciated.
#include
int main() {
// Variable’s are defined here
int dog_age = 0;
std::string dog_name = “/n”;
int early_years, int later_years, int dog_years;
//First 2 years of a dogs life
early_years = 21;
//after 2 years of age
later_years = (dog_age - 2) * 4;
//human years to dog years conversion
dog_years = early_years + later_years;
// Output of the program
std::cout << “What is your dogs name?\n”;
std::cin >> dog_name;
std::cout << “How old is your dog in human years?\n”;
std::cin >> dog_age;
std::cout << "Your dog " << dog_name << “, is " << dog_years << " dog years old\n”;
}
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!