Hello again, hope you guys can help me again ^^
Will make text red where need help.
Sry its long...

Ok, so(sorry if some things are in a diffirent language in there), the assigment is:

to make a program using a Horoscope structure

struct Horoscops{
       string name;
       int dzim[2];
       string sign;
       };

dzim = holds year/month/date
I think this is correct.
Also the program has have a list of 20 names, have that.
Has to generate a random year/month/date for each person(year from 1909-2009) - Here, for some reason can't make the random generator loop so that each person, only can get 1. So didn't include the error to make it cleaner.

The input/output has to be something like this:

Ievadiet savu vaardu ==> Iveta
Ievadiet dzimsanas datus ==> 1989 10 12

Juusu horoskopa ziime ir "Svari"

Horoskopa zimee "Svari" dzimusi ari

Janis 1965.09.29
Inga 2003.10.21

Same thing but translated....

Enter your name ==> Iveta
Enter your birth date ==> 1989 10 12

Your horoscope sign is "Svari"

The horoscope sign "Svari" is also shared by

Janis 1965.09.29
Inga 2003.10.21

To be honest, i don't rly know how to use the structure classes yet. So... help? ^^
Also i realize ill have to change the signs output from just cout "horoscope sign" , so something like sign = " horosope sign" so it can be used in the structure.
But since i don't know how to use structures properly. -.-'

Huh... also i just realized that i didnt do the

cout << "enter your name ==> ";
cin >> name;
cout <<endl << "enter your bday ==> ";
cin >> bday;

Will do that when i get some help ^^

Don't mind the outputs I have, i did that just to see if they generate everything correctly.
So this is what I got.

#include <cstdlib> 
#include <ctime> 
#include <string>
#include <iostream>

using namespace std;


struct Horoscops{
       string name;
       int dzim[2];
       string sign;
       };

void printhor (Horoscops hor);


int main()
{
    string sign;
    Horoscops mas[20];
    string names[20] = {"Billy" , "John" ,  "Jacob" , "Michael" , "Alexander" , "William" , "David" , "Ryan" , "Jack" , "Lucas", "Emily" , "Olivia"  , "Sophia" , "Alexis" , "Ashley" , "Anna" , "Victoria" , "Lauren" , "Julia" , "Sophie"};
    
 
    
    // Name Generator
    srand((unsigned)time(0)); 
    int rnames;
    rnames = (rand()%19)+1;
    

    
    //Year Generator
    srand((unsigned)time(0)); 
    int ryear;
    ryear =(rand()%100)+1909;
    

    
    //Month Generator
    srand((unsigned)time(0)); 
    int rmonth;
    rmonth = (rand()%12)+1;
    

    
    //Day Generator
    int rday;
    if( rmonth == 1 || 3 || 5 || 7 || 8 || 10 || 12){
            srand((unsigned)time(0)); 
            rday = (rand()%31)+1;
            
            }
            else if(rmonth == 4 || 6 || 9 || 11){
                     srand((unsigned)time(0)); 
                     int rday;
                     rday = (rand()%30)+1;
                     
                     }
                     else{
                           srand((unsigned)time(0)); 
                           int rday;
                           rday = (rand()%28)+1;
                           
                           }
    cout << names[rnames] << " " << ryear << " " << rmonth << " " << rday << endl;
    
    if((rmonth == 3 && rday>20) || (rmonth == 4 && rday <20)){
        cout << "Auns";
        }
        else if((rmonth == 4 && rday >19) || (rmonth == 5 && rday <21)){
             cout << "Veersis" ;
             }
             else if((rmonth == 5 && rday >20) || (rmonth == 6 && rday <22)){
                  cout << "Dviini" ;
                  }
                  else if((rmonth == 6 && rday >21) || (rmonth ==7  && rday < 23)){
                  cout << "Veerzis";
                  }
                  else if((rmonth == 7 && rday >22) || (rmonth == 8 && rday < 23)){
                       cout << "Lauva";
                       }
                       else if((rmonth == 8 && rday >22) || (rmonth == 9 && rday <23)){
                            cout << "Jaunava";
                            }
                            else if(( rmonth == 9 && rday >22) || (rmonth == 10 && rday <24)){
                                 cout << "Svari";
                                 }
                                 else if(( rmonth == 11 && rday > 21) || (rmonth == 12 && rday < 22)){
                                      cout << "Streelnieks";
                                      }
                                      else if((rmonth == 12 && rday>11)|| (rmonth == 1 && rday <20)){
                                           cout << "Mezaazis";
                                           }
                                           else if((rmonth == 1 && rday >19) ||(rmonth == 2 && rday < 19)){
                                                cout << "Uudenssviirs";
                                                }
                                                else if ((rmonth == 2 && rday >18) || (rmonth == 3 && rday < 21)){
                                                     cout << "Zivs";
                                                     }
                  cout << endl << endl;


    
   // 1 3 5 7 8 10 12 = 31
   //4 6 9 11 = 30
   //2 = 28
    
   // January , March , May , July , August , October , December - 31
   // April, June , September, November - 30
   // Febuary - 28
   
   
   
    
    
    
    

    system("PAUSE");
    return 0;
}

Recommended Answers

All 2 Replies

Your array for month/day/year is too small - should be dzim[3] don't you think? Also, I'm a little confused - why are you asking for a birth date and then doing a random date later in the program?

Ahh... ok. ill make it bigger.

but, its like...
You enter your bday(year/month/date) and it tells you yours.
The random generator randomly generates for the other 20 people(the names i have). And if any1 has same sign as mine(from the random gen.) It has to pop up in the output in the end saying.

He....
he...
she....
has the same sign as you.
I though i wrote that in the beggining =\

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.