Answered You can hire a professional tutor to get the answer.

QUESTION

#include stdio.h #include string.h #include stdlib.

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

int main()

{

char monthName[30];

char strBirthday[30];

int birthDay;

printf("n nnnGreetings, I will help you discover your astral sign! nn");

printf("Please enter the name of your birth month: ");

scanf ("%s", monthName);

printf("Thank you! Now please enter the day that you were born: ");

scanf ("%s", strBirthday);

birthDay = atoi(strBirthday);

if(birthDay < 0 || birthDay > 31){

printf("It appears you may have made a mistake in entering your birth day...");

return 0;

}

getHoroscope(monthName, birthDay);

return 0;

}

void getHoroscope(char *month, int day){

char lMonth[9]; // set the number of characters to 9, because "September" is the longest month name

char astralSign[300] = "undetermined";

char signs[12][300];

// useage of strcpy

strcpy(signs[0], "Aries, Your Element is Fire. You are Courageous, determined, confident, enthusiastic, optimistic, honest, and passionate");

strcpy(signs[1], "Taurus, Your Element is Earth. You are Reliable, patient, practical, devoted, responsible, and stable");

strcpy(signs[2], "Gemini, Your Element is Air. You are Gentle, affectionate, curious, adaptable, and have the ability to learn quickly and exchange ideas");

strcpy(signs[3], "Cancer, Your Element is Water. Tenacious, highly imaginative, loyal, emotional, sympathetic, and persuasive");

strcpy(signs[4], "Leo, Your Element is Fire. You are Creative, passionate, generous, warm-hearted, cheerful, and humorous");

strcpy(signs[5], "Virgo, Your Element is Earth. You are Loyal, analytical, kind, hardworking, and practical");

strcpy(signs[6], "Libra, Your Element is Air. You are Cooperative,diplomatic, gracious, fair-minded, and social");

strcpy(signs[7], "Scorpio, Your Element is Water. You are Resourceful, brave, passionate, stubborn, and a true friend");

strcpy(signs[8], "Sagittarius, Your Element is Fire. You are Generous, idealistic, and have a great sense of humor");

strcpy(signs[9], "Capricorn, Your Element is Earth. You are Responsible, disciplined, self-control, and have good managers");

strcpy(signs[10], "Aquarius, Your Element is Air. You are Progressive, original, independent and humanitarian");

strcpy(signs[11], "Pisces, Your Element is Water. You are Compassionate, artistic, intuitive, gentle, wise, and musical");

// Create local copy of the month variable to manipulate

/* partial copy (only 9 chars): */

strncpy(lMonth, month, 9 );

lMonth[9] = ''; /* null character manually added */

char *jan = (strstr(lMonth, "Jan") || strstr(lMonth, "jan") || strstr(lMonth, "1")) && !strstr(lMonth, "10") && !strstr(lMonth, "11");

char *feb = (strstr(lMonth, "Feb") || strstr(lMonth, "feb") || strstr(lMonth, "2"))&& !strstr(lMonth, "12");

char *mar = strstr(lMonth, "Mar") || strstr(lMonth, "mar") || strstr(lMonth, "3");

char *apr = strstr(lMonth, "Apr") || strstr(lMonth, "apr") || strstr(lMonth, "4");

char *may = strstr(lMonth, "May") || strstr(lMonth, "may") || strstr(lMonth, "5");

char *jun = strstr(lMonth, "Jun") || strstr(lMonth, "jun") || strstr(lMonth, "6");

char *jul = strstr(lMonth, "Jul") || strstr(lMonth, "jul") || strstr(lMonth, "7");

char *aug = strstr(lMonth, "Aug") || strstr(lMonth, "aug") || strstr(lMonth, "8");

char *sep = strstr(lMonth, "Sep") || strstr(lMonth, "sep") || strstr(lMonth, "9");

char *oct = strstr(lMonth, "Oct") || strstr(lMonth, "oct") || strstr(lMonth, "10");

char *nov = strstr(lMonth, "Nov") || strstr(lMonth, "nov") || strstr(lMonth, "11");

char *dec = strstr(lMonth, "Dec") || strstr(lMonth, "dec") || strstr(lMonth, "12");

if(jan){

strcpy(lMonth, "January");

if(day <=19){

strcpy(astralSign, signs[9]);

}

else{

strcpy(astralSign, signs[10]);

}

}

else if(feb){

strcpy(lMonth, "February");

if(day <=18){

strcpy(astralSign, signs[10]);

}

else{

strcpy(astralSign, signs[11]);

}

}

else if(mar){

strcpy(lMonth, "March");

if(day <=20){

strcpy(astralSign, signs[11]);

}

else{

strcpy(astralSign, signs[0]);

}

}

else if(apr){

strcpy(lMonth, "April");

if(day <=19){

strcpy(astralSign, signs[0]);

}

else{

strcpy(astralSign, signs[1]);

}

}

else if(may){

strcpy(lMonth, "May");

if(day <=20){

strcpy(astralSign, signs[1]);

}

else{

strcpy(astralSign, signs[2]);

}

}

else if(jun){

strcpy(lMonth, "June");

if(day <=20){

strcpy(astralSign, signs[2]);

}

else{

strcpy(astralSign, signs[3]);

}

}

else if(jul){

strcpy(lMonth, "July");

if(day <=22){

strcpy(astralSign, signs[3]);

}

else{

strcpy(astralSign, signs[4]);

}

}

else if(aug){

strcpy(lMonth, "August");

if(day <=22){

strcpy(astralSign, signs[4]);

}

else{

strcpy(astralSign, signs[5]);

}

}

else if(sep){

strcpy(lMonth, "September");

if(day <=22){

strcpy(astralSign, signs[5]);

}

else{

strcpy(astralSign, signs[6]);

}

}

else if(oct){

strcpy(lMonth, "October");

if(day <=22){

strcpy(astralSign, signs[6]);

}

else{

strcpy(astralSign, signs[7]);

}

}

else if(nov){

strcpy(lMonth, "November");

if(day <=21){

strcpy(astralSign, signs[7]);

}

else{

strcpy(astralSign, signs[8]);

}

}

else if(dec){

strcpy(lMonth, "December");

if(day <=21){

strcpy(astralSign, signs[8]);

}

else{

strcpy(astralSign, signs[9]);

}

}

else{

printf("nIt appears you may have made a mistake in entering your birth month...");

}

printf("nFor the birth date of %s %d your Astral sign is %s", lMonth, day, astralSign);

}

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question