Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make a class that checks what your Chinese horoscope is. The Horoscope class wil

ID: 3802178 • Letter: M

Question

Make a class that checks what your Chinese horoscope is.

The Horoscope class will have the following private attributes

string sign;

String dob // date of birth, mm / dd / yyyy

string //date of star

string // date end

Make a default constructor should initialize with your information according to the date of birth.

Make a parameter constructor that will only receive the date of birth, and the constructor will be in charge of updating the other attributes.

Make setter and getter for the dob attribute. Where the setter will update the other attributes as well.

Make getters d the attributes sign, date and end Date

Make a method that calculates which is your Chinese sign, that is called void compute Sign0

Make a method void display () where you will print the information of the sign

Make a main to test your class.

Use the following multidimensional array

const string SIGNS [9] [3] Horse "," 19900127 "," 19910214 ")

Cabral 1991 0215 19920203

Mono", 19920204 19930122)

Gallo 19930123 19940209

Dog ", 19940209 19950130

Pork 19950131 19960218 Rata 19960219 19970206

Ox ", 19970207 19980127 Tiger", 19980128 19990215

Tip: Use substr to change the format of the date of birth.

Reference for horoscope Chinese https. En.wikipedia.org/wiki/Chinese zodiac

output Example # 1: Enter your date of birth (mm / ddlyyyy): 09/01/1993

Sign: Rooster

Date of birth: 09/01/1993 Period of Date: 01/23/1993 02/09/1994

output Example # 2: Enter your date of birth

Explanation / Answer

#include<iostream>
using namespace std;

class horoscope{
private:
   std::string sign;
   std::string dob;
   std::string dos;
   std::string doe;
   const std::string SIGNS[9][3] = {
                       {"Horse","19900127","19910214"},
                       {"Cabral","19910215","19920203"},
                       {"Mono","19920204","19930122"},
                       {"Gallo","19930123","19940209"},
                       {"Dog","19930123","19940209"},
                       {"Pork","19950131","19960218"},
                       {"Rata","19960219","19970206"},
                       {"Ox","19970207","19980127"},
                       {"Tiger","19980128","19990215"}
                   };


public:
   horoscope()
   {
       get_dob();

   }

   horoscope(std::string DOB)
   {

       dob = DOB;
       convert_dob();
       compute_sign();
   }
   void convert_dob()
   {
      
       std::string month = dob.substr(0,2);
       std::cout<<month<<endl;
       std::string day = dob.substr(3,2);
       std::cout<<day<<endl;
       std::string year = dob.substr(6);
       std::cout<<year<<endl;
       dob = month+day+year;
       cout << "DOB="<<dob<<endl;

   }
   void get_dob()
   {
       cout << "Please enter dob"<<endl;
       cin >> dob;
       convert_dob();
       compute_sign();
   }
  
   void compute_sign()
   {
       int day = std::stoi(dob.substr(2,2));
       int month = std::stoi(dob.substr(0,2));
       int year = std::stoi(dob.substr(4));
       int i=0;
       for(i=0;i<9;i++)
       {
           int temp_day_start,temp_day_end,temp_month_start,temp_month_end,temp_year_start,temp_year_end;
           temp_year_start = std::stoi(SIGNS[i][1].substr(0,4));
           temp_month_start = std::stoi(SIGNS[i][1].substr(4,2));
           temp_day_start = std::stoi(SIGNS[i][1].substr(6,2));
          
           temp_year_end = std::stoi(SIGNS[i][2].substr(0,4));
           temp_month_end = std::stoi(SIGNS[i][2].substr(4,2));
           temp_day_end = std::stoi(SIGNS[i][2].substr(6,2));
           if(temp_year_start <= year && temp_month_start <= month && temp_day_start <= day && temp_year_end >= year && temp_month_end >= month && temp_day_end >= day)
           {
               sign = SIGNS[i][0];
               dos = SIGNS[i][1];
               doe = SIGNS[i][2];
               break;

           }
      
          
       }

   }

   void display()
   {
       std::cout << "Sign = " << sign<<endl;
   }

   void get()
   {
       cout<<"Sign = "<<sign<<endl;
       cout<<"date of Start="<<dos<<endl;
       cout<<"date of end="<<doe<<endl;
   }

};


int main()
{
  
class horoscope horo1;
class horoscope hor2("02/05/1993");
horo1.get();
hor2.get();


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote