Click here to Skip to main content
15,921,959 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: int const& Pin
George_George9-Aug-08 1:29
George_George9-Aug-08 1:29 
GeneralRe: int const& Pin
Hamid_RT18-Feb-08 7:27
Hamid_RT18-Feb-08 7:27 
GeneralRe: int const& Pin
George_George18-Feb-08 19:47
George_George18-Feb-08 19:47 
GeneralRe: int const& Pin
Hamid_RT18-Feb-08 20:08
Hamid_RT18-Feb-08 20:08 
GeneralRe: int const& Pin
George_George18-Feb-08 20:12
George_George18-Feb-08 20:12 
GeneralRe: int const& Pin
Hamid_RT18-Feb-08 20:44
Hamid_RT18-Feb-08 20:44 
GeneralRe: int const& Pin
George_George18-Feb-08 20:54
George_George18-Feb-08 20:54 
JokeRe: int const& Pin
Hamid_RT18-Feb-08 21:18
Hamid_RT18-Feb-08 21:18 
QuestionDetermining OS type: 32-bit or 64-bit, programmatically. Pin
eyalbi00716-Feb-08 21:45
eyalbi00716-Feb-08 21:45 
GeneralRe: Determining OS type: 32-bit or 64-bit, programmatically. Pin
Garth J Lancaster16-Feb-08 22:56
professionalGarth J Lancaster16-Feb-08 22:56 
GeneralRe: Determining OS type: 32-bit or 64-bit, programmatically. Pin
eyalbi00716-Feb-08 23:47
eyalbi00716-Feb-08 23:47 
GeneralRe: Determining OS type: 32-bit or 64-bit, programmatically. Pin
Robert M Greene17-Feb-08 6:09
Robert M Greene17-Feb-08 6:09 
GeneralRe: Determining OS type: 32-bit or 64-bit, programmatically. Pin
Garth J Lancaster17-Feb-08 10:04
professionalGarth J Lancaster17-Feb-08 10:04 
QuestionC++ And XFS Pin
Buddhika Jayasinghe16-Feb-08 19:52
Buddhika Jayasinghe16-Feb-08 19:52 
GeneralRegistry Pin
Bram van Kampen16-Feb-08 14:38
Bram van Kampen16-Feb-08 14:38 
GeneralRe: Registry Pin
CPallini16-Feb-08 23:21
mveCPallini16-Feb-08 23:21 
QuestionRe: Registry Pin
Bram van Kampen17-Feb-08 3:17
Bram van Kampen17-Feb-08 3:17 
GeneralRe: Registry Pin
Rajkumar R17-Feb-08 3:52
Rajkumar R17-Feb-08 3:52 
GeneralRe: Registry Pin
Bram van Kampen17-Feb-08 6:19
Bram van Kampen17-Feb-08 6:19 
AnswerRe: Registry Pin
Rajkumar R17-Feb-08 17:14
Rajkumar R17-Feb-08 17:14 
GeneralRe: Registry Pin
Hamid_RT18-Feb-08 7:18
Hamid_RT18-Feb-08 7:18 
QuestionCapture the ID Button clicked by mouse in a game Pin
Rafael Pacheco16-Feb-08 13:37
Rafael Pacheco16-Feb-08 13:37 
QuestionRe: Capture the ID Button clicked by mouse in a game Pin
Rajkumar R17-Feb-08 2:26
Rajkumar R17-Feb-08 2:26 
Questionnoob needs some help with C++ programming class Pin
boomer7916-Feb-08 13:09
boomer7916-Feb-08 13:09 
GeneralNevermind, figured it out... Pin
boomer7916-Feb-08 14:16
boomer7916-Feb-08 14:16 
But I do need some advice on what to do to give the user an option to continue using the program or to exit. My completed code is below. Thanks.


// **************************************************************************
//
// Astrology.cpp
//
// Prompts for the user's birthday and returns the user's
// astrological sign.
// **************************************************************************
#include <iostream>

int getMonth();
// Precondition: User will enter birth month
// Postcondition: Returns 1 <= birth month <= 12

int getDay();
// Precondition: User will enter birth day
// Postcondition: Returns 1 <= birth day <= 31

int getSign(int month, int day);
// Precondition: 1 <= month <= 12, 1 <= day <= 31
// Postcondition: Returns integer corresponding to astrological sign for
// given month and day starting with Capricorn = 1.

int main()
{
using namespace std;
int month;
int day;

//
// Get birth month and day.
//

month = getMonth();
day = getDay();

//
// Determine and print the user's sign
//

cout << "Your sign is ";


// --------------------------------
// ----- ENTER YOUR CODE HERE -----
// --------------------------------
switch (month)
{
case 1:
if (day <= 19)
cout << "Capricorn.";
else
cout <<"Aquarius.";
break;
case 2:
if (day <= 18)
cout << "Aquarius.";
else
cout <<"Pisces.";
break;
case 3:
if (day <= 20)
cout << "Pisces.";
else
cout <<"Aries.";
break;
case 4:
if (day <= 19)
cout << "Pisces.";
else
cout <<"Taurus.";
break;
case 5:
if (day <= 20)
cout << "Taurus.";
else
cout <<"Gemini.";
break;
case 6:
if (day <= 20)
cout << "Gemini.";
else
cout <<"Cancer.";
break;
case 7:
if (day <= 22)
cout << "Cancer.";
else
cout <<"Leo.";
break;
case 8:
if (day <= 22)
cout << "Leo.";
else
cout <<"Virgo.";
break;
case 9:
if (day <= 22)
cout << "Virgo.";
else
cout <<"Libra.";
break;
case 10:
if (day <= 22)
cout << "Libra.";
else
cout <<"Scorpio.";
break;
case 11:
if (day <= 21)
cout << "Scorpio.";
else
cout <<"Sagittarius.";
break;
case 12:
if (day <= 21)
cout << "Sagittarius.";
else
cout <<"Capricorn.";
break;
}
// --------------------------------
// --------- END USER CODE --------
// --------------------------------


cout << endl;

}


int getMonth()
{
using namespace std;

int month;
cout << "Enter the month of your birthday (1-12): ";
cin >> month;
while ((month < 1) || (month > 12))
{
cout << "Month must be between 1 and 12; please re-enter: ";
cin >> month;
}
return month;
}


int getDay()
{
using namespace std;

int day;
cout << "Enter the day of your birthday (1-31): ";
cin >> day;
while ((day < 0) || (day > 31))
{
cout << "Day must be between 1 and 31; please re-enter: ";
cin >> day;
}
return day;
}

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.