Just basically doing a project for myself. Basically writing a simple program to show your age and your horoscope sign. I am displaying the output I want except the age is wrong. I'm trying to figure out why. I'm thinking because I'm subtracting the year.
My Birthday is 7 14 1991
It outputs my age is 29. I am 28
Just wondering how I can put July instead of 7. Pretty sure i will have to do alot of if and then statements for the horoscope.
Here is the code
#include <iostream>
#include <ctime>
#include <string>
using namespace std;
struct Customer_info
{
string Customer_Name;
int Customer_Month;
int Customer_Day;
int Customer_Year;
};
int main()
{
Customer_info cust;
cout << "What is your name? And when exactly is your birthday?" << endl;
getline (cin, cust.Customer_Name);
cin >> cust.Customer_Month;
cin >> cust.Customer_Day;
cin >> cust.Customer_Year;
cout << "Your name is " << cust.Customer_Name << " " << "and you were born " << cust.Customer_Month << endl;
time_t now = time(0);
tm *date = localtime(&now);
cout << "The date is " << 1 + date->tm_mon << " / " << date->tm_mday << " / " << 1900 + date->tm_year << endl ;
int age;
age = 1900 + date-> tm_year - cust.Customer_Year;
cout << "Your age is " << age << endl;
return 0;
}