Click here to Skip to main content
15,923,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Enums Pin
David Crow25-Mar-04 2:48
David Crow25-Mar-04 2:48 
GeneralRe: Enums Pin
monrobot1325-Mar-04 18:33
monrobot1325-Mar-04 18:33 
Generalimproving a hack Pin
axid3j1al24-Mar-04 20:25
axid3j1al24-Mar-04 20:25 
QuestionHow to popup the application-menu ? Pin
ohadp24-Mar-04 20:16
ohadp24-Mar-04 20:16 
GeneralError in calling DLL Pin
dafan24-Mar-04 19:14
dafan24-Mar-04 19:14 
GeneralRe: Error in calling DLL Pin
dafan25-Mar-04 2:41
dafan25-Mar-04 2:41 
GeneralA Loop...homework tips please! Pin
Joe Estes24-Mar-04 18:27
Joe Estes24-Mar-04 18:27 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright24-Mar-04 19:54
professionalRoger Wright24-Mar-04 19:54 
Try this:

Change getInput() to return a value - 0 to quit, 1 to continue -

int getInput() <br />
{ <br />
char vType;<br />
<br />
cout << "Enter the type of car"; <br />
cout << endl; <br />
cout << "(e.g. 'C' for car, 'T' for truck, or 'S' for senior citizen: "; <br />
cout << endl; <br />
cout << "Press X to exit program : ";<br />
cin >> vType; <br />
cout << endl; <br />
if (tolower(vType) == 'x') <br />
{ <br />
return 0; <br />
} <br />
cout <<"Enter the number of minutes the vehicle has been parked: "; <br />
cin >> mtime; <br />
<br />
computePrice(vType,mtime);<br />
return 1; <br />
}


And change main() -

int main() <br />
{ <br />
int run = 1; //variable to indicate whether to continue<br />
while(run)   //Run always at least one time; exit if that last input was x<br />
{<br />
run = getInput(); <br />
cin.ignore(); //I have no idea why<br />
cin.get();    //these are needed, but keep them if they help<br />
}<br />
return 0; <br />
}


Crude, I know, but I'm a beginner, too. Blush | :O

Will Build Nuclear Missile For Food - No Target Too Small
GeneralRe: A Loop...homework tips please! Pin
Prakash Nadar24-Mar-04 20:16
Prakash Nadar24-Mar-04 20:16 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright24-Mar-04 20:46
professionalRoger Wright24-Mar-04 20:46 
GeneralRe: A Loop...homework tips please! Pin
Prakash Nadar24-Mar-04 20:54
Prakash Nadar24-Mar-04 20:54 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright24-Mar-04 21:00
professionalRoger Wright24-Mar-04 21:00 
GeneralRe: A Loop...homework tips please! Pin
peterzorbas24-Mar-04 21:40
peterzorbas24-Mar-04 21:40 
GeneralRe: A Loop...homework tips please! Pin
peterzorbas24-Mar-04 21:58
peterzorbas24-Mar-04 21:58 
GeneralRe: A Loop...homework tips please! Pin
peterzorbas24-Mar-04 21:57
peterzorbas24-Mar-04 21:57 
GeneralRe: A Loop...homework tips please! Pin
Paul Ranson25-Mar-04 2:35
Paul Ranson25-Mar-04 2:35 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright25-Mar-04 5:55
professionalRoger Wright25-Mar-04 5:55 
GeneralRe: A Loop...homework tips please! Pin
Paul Ranson25-Mar-04 6:42
Paul Ranson25-Mar-04 6:42 
GeneralRe: A Loop...homework tips please! Pin
Roger Wright25-Mar-04 7:59
professionalRoger Wright25-Mar-04 7:59 
GeneralRe: A Loop...homework tips please! Pin
Maxwell Chen25-Mar-04 16:55
Maxwell Chen25-Mar-04 16:55 
Generalsave application Pin
archanagaby24-Mar-04 17:44
archanagaby24-Mar-04 17:44 
GeneralRe: save application Pin
David Crow25-Mar-04 8:59
David Crow25-Mar-04 8:59 
GeneralSplit CString Pin
Simon Poon24-Mar-04 15:45
Simon Poon24-Mar-04 15:45 
GeneralRe: Split CString Pin
David Salter24-Mar-04 22:14
David Salter24-Mar-04 22:14 
GeneralRe: Split CString Pin
Steve S25-Mar-04 1:19
Steve S25-Mar-04 1:19 

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.