Help needed for simple program, would be grateful

  • Thread starter sheepcountme
  • Start date
  • Tags
    Program
In summary, the individual is seeking help with a code for an astrology program they wrote. The program asks for the user's birth month and day, but then does not output anything. They are asking for assistance in fixing the issue and received advice to open the program through a terminal. They also added a code to allow for time to read the program's output.
  • #1
sheepcountme
80
1
I'm dead awful at computer science, but I have to take the class, and I'm struggling.

I wrote the following code for an astrology program (I'm sure it's completely awkward, but please bear with me, it at least made it through a successful build).

The problem is, it asks for the month and day, but then just ends and doesn't output anything. Any help you could give me to fix this would be very much appreciated. The book hasn't been much help at all.

Here's the code...

#include <iostream>
using namespace std;

int main()

{
int month, day;

cout << "Enter the month you were born, from 1 to 12. ";
cin >> month;

cout << "Enter the day you were born from 1 to 31. ";
cin >> day;

if ( (month==10&&day>25) || (month==11&&day<19) ) {
cout << "You are a Scorpio! Today you should eat lots of cookies! ";
} else if ( (month==11&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Scorpio and Sagittarius! ";
cout << "Today you should eat lots of cookies and pet a kitten! ";
} else if ( (month==11&&day>24) || (month==12&&day<19) ) {
cout << "You are a Sagittarius! Today you should pet a kitten! ";
} else if ( (month==12&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Sagittarius and Capricorn! ";
cout << "Today you should pet a kitten and beware of snails! ";
} else if ( (month==12&&day>24) || (month==1&&day<17) ) {
cout << "You are a Capricorn! Beware of snails today! ";
} else if ( (month==1&&day>=17&&day<=22) ) {
cout << "You were born on the cusp of Capricorn and Aquarius! ";
cout << "Beware of snails today and bring an umbrella! ";
} else if ( (month==1&&day>22) || (month==2&&day<16) ) {
cout << "You are an Aquarius! Bring an umbrella today! ";
} else if ( (month==2&&day>=16&&day<=21) ) {
cout << "You were born on the cusp of Aquarius and Pisces! ";
cout << "Bring an umbrella today and wear something pink! ";
} else if ( (month==2&&day>21) || (month==3&&day<18) ) {
cout << "You are a Pisces! Wear something pink today! ";
} else if ( (month==3&&day>=18&&day<=23) ) {
cout << "You were born on the cusp of Pisces and Aries! ";
cout << "Wear something pink today and beware of cheese! ";
} else if ( (month==3&&day>23) || (month==4&&day<17) ) {
cout << "You are an Aries! Beware of cheese today! ";
} else if ( (month==4&&day>=17&&day<=22) ) {
cout << "You were born on the cusp of Aries and Taurus! ";
cout << "Beware of cheese today and wear your pants backwards! ";
} else if ( (month==4&&day>22) || (month==5&&day<18) ) {
cout << "You are a Taurus! Wear your pants backwards today! ";
} else if ( (month==5&&day>=18&&day<=23) ) {
cout << "You were born on the cusp of Taurus and Gemini! ";
cout << "Wear your pants backwards today and speak in Italian! ";
} else if ( (month==5&&day>23) || (month==6&&day<19) ) {
cout << "You are a Gemini! Speak in Italian today! ";
} else if ( (month==6&&day>=19&&day<=24) ) {
cout << "You were born on the cusp of Gemini and Cancer! ";
cout << "Speak in Italian today and kiss a walrus! ";
} else if ( (month==6&&day>24) || (month==7&&day<20) ) {
cout << "You are a Cancer! Kiss a walrus today! ";
} else if ( (month==7&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Cancer and Leo! ";
cout << "You shold kiss a walrus today and wear a tuxedo! ";
} else if ( (month==7&&day>25) || (month==8&&day<20) ) {
cout << "You are a Leo! You should wear a tuxedo today! ";
} else if ( (month==8&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Leo and Virgo! ";
cout << "Today you should wear a tuxedo and call everyone 'Henry'! ";
} else if ( (month==8&&day>25) || (month==9&&day<20) ) {
cout << "You are a Virgo! Today you should call everyone 'Henry'! ";
} else if ( (month==9&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Virgo and Libra! ";
cout << "Today you should call everyone 'Henry' and do the moonwalk! ";
} else if ( (month==9&&day>25) || (month==10&&day<20) ) {
cout << "You are a Libra! Today you should do the moonwalk! ";
} else if ( (month==10&&day>=20&&day<=25) ) {
cout << "You were born on the cusp of Libra and Scorpio! ";
cout << "Today you should do the moonwalk and eat lots of cookies! ";

}


}
 
Technology news on Phys.org
  • #2
It works for me.

My theory is you are compiling it and double clicking the binary produced. Have you ever tried opening the program via a terminal?

I'll just assume you are using windows and you should open the command prompt, navigate to the directory where you compiled it, and open it in the prompt.

If you are unfamiliar with command prompts, you can always add a little code bit at the end that can retrieve another keystroke so that you can have time to read what your program has printed out.
 
  • #3
Great, thank you! Turns out it just wouldn't stay up long enough for me to see the result. Thanks a lot!
 

1. What type of program is it?

The type of program needed can vary, but it could be a simple computer program, a mobile app, or even a web application.

2. What programming language is required?

The programming language needed will depend on the type of program and the specific requirements. Some common programming languages include Java, Python, JavaScript, and C++. It is important to determine the best language for your specific needs.

3. What is the deadline for completing the program?

The deadline for completing the program should be clearly stated and agreed upon by both parties. This will help ensure that the project stays on track and is completed in a timely manner.

4. What is the purpose of the program?

The purpose of the program should be clearly defined and understood by both parties. This will help guide the development process and ensure that the end result meets the desired goals and objectives.

5. Will there be ongoing support or updates needed?

It is important to discuss and determine if there will be ongoing support or updates needed for the program after it is completed. This could impact the overall timeline and cost of the project.

Similar threads

  • Programming and Computer Science
Replies
19
Views
961
Replies
4
Views
1K
  • Biology and Medical
9
Replies
287
Views
18K
  • General Math
Replies
2
Views
6K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • General Discussion
Replies
20
Views
2K
  • STEM Career Guidance
Replies
2
Views
2K
  • Math Proof Training and Practice
2
Replies
67
Views
10K
Replies
38
Views
4K
  • Precalculus Mathematics Homework Help
Replies
13
Views
4K
Back
Top