Reputation: 89
I'm required to write a program that gives a person’s day and month of birth and will then figure out the person’s horoscope sign. The program should prompt the user for a number of persons. When the user responds, the program needs to automatically generate day and month and figure out and display the corresponding horoscope sign. The program also needs to track number of persons for each sign and display that statistics. After that, the program needs to prompt the user if they want to go again. If the user responds with either a ‘Y’ or a ‘y’ the program needs to repeat the process until the user says that s/he is done.
I have a learning disability and i find it hard to understand sometimes what the questions that are being asked. I do not know how to answer them sometimes. So please be patience with me.
#include <ctime>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
int month, date, i, nOfPeople;
i = 0;
cout << "How many people: " << endl;
cout << "Born on Horoscope Sign" << endl;
cout << "-------------------------" << endl;
cin >> nOfPeople;
while (i < nOfPeople) {
// initialize random seed:
srand(time(NULL))
// generate month and date
month = rand() % 12 + 1;
date = rand() % 28 + 1;
if (month == 3 && date >= 21 || month == 4 && date <= 19) {
cout << "4/19 Aries" << endl;
} else if (month == 4 && date >= 20 || month == 5 && date <= 20) {
cout << "5/7 Taurus" << endl;
} else if (month == 5 && date >= 21 || month == 6 && date <= 21) {
cout << "Gemini" << endl;
} else if (month == 6 && date >= 22 || month == 7 && date <= 22) {
cout << "7/8 Cancer" << endl;
} else if (month == 7 && date >= 23 || month == 8 && date <= 22) {
cout << "8/17 Leo" << endl;
} else if (month == 8 && date >= 23 || month == 9 && date <= 22) {
cout << "Virgo" << endl;
} else if (month == 9 && date >= 23 || month == 10 && date <= 22) {
cout << "Libra" << endl;
} else if (month == 10 && date >= 23 || month == 11 && date <= 21) {
cout << "11/3 Scorpio" << endl;
} else if (month == 11 && date >= 22 || month == 12 && date <= 21) {
cout << "12/11 Saguittarius" << endl;
} else if (month == 12 && date >= 22 || month == 1 && date <= 19) {
cout << "12/22 Capricorn" << endl;
} else if (month == 1 && date >= 20 || month == 2 && date <= 18) {
cout << "Aquarius" << endl;
} else if (month == 2 && date >= 19 || month == 3 && date <= 20) {
cout << "2/21 Pieces" << endl;
}
i++;
}
return 0;
}
Upvotes: 0
Views: 10423
Reputation: 29985
std::rand
and std::srand
are defined in <cstdlib>
. Include that header then you should be able to use those functions.
Upvotes: 3