Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: TcpClient in Visual C++ Pin
tibiz18-Feb-08 11:58
tibiz18-Feb-08 11:58 
GeneralCreating Services -- transitioning from interactive window app.... Pin
Peter Weyzen18-Feb-08 10:31
Peter Weyzen18-Feb-08 10:31 
GeneralRe: Creating Services -- transitioning from interactive window app.... Pin
Mark Salsbery18-Feb-08 10:35
Mark Salsbery18-Feb-08 10:35 
GeneralRe: Creating Services -- transitioning from interactive window app.... Pin
Peter Weyzen18-Feb-08 18:18
Peter Weyzen18-Feb-08 18:18 
GeneralRe: Creating Services -- transitioning from interactive window app.... Pin
Mark Salsbery19-Feb-08 6:17
Mark Salsbery19-Feb-08 6:17 
GeneralRe: Creating Services -- transitioning from interactive window app.... Pin
Peter Weyzen19-Feb-08 9:01
Peter Weyzen19-Feb-08 9:01 
GeneralRe: Creating Services -- transitioning from interactive window app.... Pin
Mark Salsbery19-Feb-08 9:32
Mark Salsbery19-Feb-08 9:32 
QuestionWill someone please help me? Pin
boomer7918-Feb-08 10:30
boomer7918-Feb-08 10:30 
I'm trying to figure out how to place a loop in this program that will take input from the user after each iteration, ask to continue, and restart or exit the program. I've tried everything, I just don't know how to do it. Will someone please take a look at this code and maybe put the loop statements in the right spots? I'm really lost and I just need this one example done so I can understand it and move on. Thanks.


#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;
cout << "Do you want to continue? (Y/N)\n";



}


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;
}
GeneralRe: Will someone please help me? Pin
CPallini18-Feb-08 10:37
mveCPallini18-Feb-08 10:37 
GeneralRe: Will someone please help me? Pin
boomer7918-Feb-08 10:39
boomer7918-Feb-08 10:39 
GeneralRe: Will someone please help me? Pin
CPallini18-Feb-08 21:37
mveCPallini18-Feb-08 21:37 
GeneralRe: Will someone please help me? Pin
Mark Salsbery18-Feb-08 10:46
Mark Salsbery18-Feb-08 10:46 
GeneralRe: Will someone please help me? Pin
boomer7918-Feb-08 11:40
boomer7918-Feb-08 11:40 
GeneralRe: Will someone please help me? Pin
BadKarma18-Feb-08 12:33
BadKarma18-Feb-08 12:33 
GeneralRe: Will someone please help me? Pin
boomer7919-Feb-08 6:05
boomer7919-Feb-08 6:05 
GeneralPointer - output Pin
daavena18-Feb-08 10:18
daavena18-Feb-08 10:18 
GeneralRe: Pointer - output Pin
willy_total18-Feb-08 10:30
willy_total18-Feb-08 10:30 
GeneralRe: Pointer - output Pin
daavena18-Feb-08 10:47
daavena18-Feb-08 10:47 
GeneralRe: Pointer - output Pin
Mark Salsbery18-Feb-08 10:30
Mark Salsbery18-Feb-08 10:30 
GeneralRe: Pointer - output Pin
CPallini18-Feb-08 10:34
mveCPallini18-Feb-08 10:34 
GeneralRe: Pointer - output Pin
Mark Salsbery18-Feb-08 10:38
Mark Salsbery18-Feb-08 10:38 
GeneralRe: Pointer - output Pin
daavena18-Feb-08 10:44
daavena18-Feb-08 10:44 
QuestionPossible Vista bug? Pin
DougVC18-Feb-08 8:07
DougVC18-Feb-08 8:07 
AnswerRe: Possible Vista bug? Pin
Mark Salsbery18-Feb-08 8:52
Mark Salsbery18-Feb-08 8:52 
GeneralRe: Possible Vista bug? Pin
DougVC18-Feb-08 11:04
DougVC18-Feb-08 11:04 

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.