Click here to Skip to main content
15,922,155 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Can I add picture with SetBitmap function ? Pin
MAAK23-Feb-03 9:10
MAAK23-Feb-03 9:10 
Generalwhich function is in the middle of ... Pin
includeh1023-Feb-03 8:06
includeh1023-Feb-03 8:06 
GeneralRe: which function is in the middle of ... Pin
Stephane Rodriguez.23-Feb-03 9:32
Stephane Rodriguez.23-Feb-03 9:32 
GeneralCDROM manage Pin
Anonymous23-Feb-03 6:20
Anonymous23-Feb-03 6:20 
GeneralPlease Help! c++ newbie Pin
Pete Forster23-Feb-03 5:30
sussPete Forster23-Feb-03 5:30 
GeneralRe: Please Help! c++ newbie Pin
valikac23-Feb-03 7:46
valikac23-Feb-03 7:46 
GeneralRe: Please Help! c++ newbie Pin
Pete Forster23-Feb-03 9:01
sussPete Forster23-Feb-03 9:01 
GeneralRe: Please Help! c++ newbie Pin
Christian Graus23-Feb-03 9:59
protectorChristian Graus23-Feb-03 9:59 
The other poster was right - we're glad to help, but we won't do your homework for you.

Pete Forster wrote:
#include //IO Library Mandatory
#include //Standard Library for DOS commands Mandatory
//#include //Includes String library
using namespace std; //For object orientation Mandatory


As a matter of form, it's better to use the syntax

using std::endl;
using std::cout;

etc. Do you *need* to use the dos library ? I think it's a bit ugly, personally.

Also, the includes didn't show up because you didn't tick 'display this message as-is', or use the buttons above the smileys to put in <> as &lt &gt. I presume you included <iostream> and <string> as opposed to <iostream.h> and <string.h> ? If not, the code is wrong and reference to namespace std is superfluous.


Pete Forster wrote:
cout<<"Please enter pin"<<endl;
cin>>pin;

while ((pin !=1234) && (wrongpin !=3));
{
wrongpin = wrongpin+1;
cout<<"Error Wrong Pin"<<endl;
cout<<"please enter="" pin"<<endl;
cin="">>pin;

}
else if ((pin==1234) && (wrongpin !=3));


Your while and if statements have semicolons after them. I suspect this is your main problem. The semicolon means that the code afterwards is always run. This can be valid, a loop and perform the desired actions by itself at times, but you want this

while (pin != 1234 && wrongpin <3 ) // no semicolon and extra brackets were superfluous.
{
++wrongpin; // Same as wrongpin = wrongpin + 1
// etc.
}

I'd also be inclined to use do...while loops so your input statement need only occur the once.

Pete Forster wrote:
while ((mmchoice !=1) && (mmchoice !=2) && (mmchoice !=3) && mmchoice !=4)

Just a suggestion, but this would be tighter as

while (mmchoice < 1 || mmchoice > 4)

Also, you created all these variables at the top, and a lot of them are just reused temporaries. C requires variables declared at the top, for C++, I prefer to declare them as I need them. They are only ints today, but if you're creating something resource hungry, it's better not to do it until you need it. ( Of course, if your teacher is an old C programmer, he may disagree and it may cost you marks, so ask him/her first )


Pete Forster wrote:
if (money >500)
cout<<"Your overdraft has been approved!"<<endl;

system("pause");

return 0;

if="" ((money="" <="500)" &&="" (money="">250));
cout<<"Please contact your branch"
system("pause")

return 0;

if (money <=250);
cout<<"Sorry you cannot have an overdraft"
system("pause")


Two problems here ( unless I'm misreading the code ).

1. 'Magic' numbers are evil. If you want to have a a limit, set it at the top of your code like this:

const int nMaximumWithdrawal = 500;

Then if you want to change the value later, you can do so easily without introducing bugs.

2. I suspect this code is supposed to refer to the customers balance to check if it's an overdraft, instead of a predefined value.

Good luck !!!


Christian

No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002

C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002


It'd probably be fairly easy to make a bot that'd post random stupid VB questions, and nobody would probably ever notice - benjymous - 21-Jan-2003
GeneralRe: Please Help! c++ newbie Pin
Big Art23-Feb-03 10:23
Big Art23-Feb-03 10:23 
Generalconvert CString to HEX Pin
afender23-Feb-03 3:48
afender23-Feb-03 3:48 
GeneralRe: convert CString to HEX Pin
Abin23-Feb-03 4:13
Abin23-Feb-03 4:13 
GeneralRe: convert CString to HEX Pin
Gary R. Wheeler23-Feb-03 4:42
Gary R. Wheeler23-Feb-03 4:42 
Generalcheck box Pin
dudic23-Feb-03 1:05
dudic23-Feb-03 1:05 
GeneralRe: check box Pin
Hans Ruck23-Feb-03 3:28
Hans Ruck23-Feb-03 3:28 
QuestionHow to use Microsoft Layer for Unicode with MFC app Pin
Valera24117623-Feb-03 0:03
Valera24117623-Feb-03 0:03 
AnswerRe: How to use Microsoft Layer for Unicode with MFC app Pin
dan o23-Feb-03 23:32
dan o23-Feb-03 23:32 
GeneralBitmaps again... Pin
Dennis L22-Feb-03 22:46
Dennis L22-Feb-03 22:46 
GeneralRe: Bitmaps again... Pin
Joaquín M López Muñoz23-Feb-03 5:10
Joaquín M López Muñoz23-Feb-03 5:10 
GeneralRe: Bitmaps again... Pin
MAAK23-Feb-03 9:44
MAAK23-Feb-03 9:44 
GeneralSplitting a CString Pin
ROK_RShadow22-Feb-03 21:38
ROK_RShadow22-Feb-03 21:38 
GeneralRe: Splitting a CString Pin
Pavel Klocek23-Feb-03 1:25
Pavel Klocek23-Feb-03 1:25 
GeneralRe: Splitting a CString Pin
Big Art23-Feb-03 10:48
Big Art23-Feb-03 10:48 
GeneralRe: Splitting a CString Pin
ROK_RShadow23-Feb-03 12:36
ROK_RShadow23-Feb-03 12:36 
GeneralRe: Splitting a CString Pin
Big Art24-Feb-03 5:21
Big Art24-Feb-03 5:21 
GeneralNeed help on some weird errors Pin
Abin22-Feb-03 20:23
Abin22-Feb-03 20:23 

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.