Need to "Exit Stage Left" on this small program... I am working out of "C - How to program"... Working as many Exercises from each Chapter... I understand the concept of using "Sentinel Values" to exit a program in which you dont know how many factors will be inPuted...
I just can't seem to exit when I am asking the user for multiple inPuts.. I did find a simple "Sentinel Exit" and have been trying to work off it..... Please excuse sloppy errors... I am trying to build a fondation of programming and have found that pounding daily programs is what will make the difference in the End,,, < Which I hope will lead to a New Begenning!!!!!
Any Hints or Help will be appreciated....
#include "stdafx.h"
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
/* Determine if customer has Exceeded Credit Limit */
/* variables */
int acctNum;
// int cnter;
double crdtBegBall ; /* Begenning Credit Ballance */
double totChrges; /* Total Charges */
double totCrdtd; /* Total Credit */
double crdtLmt; /* Credit Limit */
double totCrdtBall = 0; /* crdtBegBall + totCrdtd */
/* processing phase - get input from User */
printf("\nEnter Account Number (1- to end): ");
scanf("%d", &acctNum); /* priming Read */
printf("\nEnter Beggenning Credit Ballance: ");
scanf("%d", &crdtBegBall);
printf("\nEnter Total Charges: ");
scanf("%d", &totChrges);
printf("\nEnter Total Credit: ");
scanf("%d", &totCrdtd);
printf("\nEnter Credit Limit: ");
scanf("%d", &crdtLmt);
while (acctNum != -1)
{
totCrdtBall = crdtBegBall + totCrdtd;
printf("\nEnter Account Number (1- to end): ");
scanf("%d", &acctNum); /* Repeating Read */
printf("\nEnter Beggenning Credit Ballance: ");
scanf("%d", &crdtBegBall);
printf("\nEnter Total Charges: ");
scanf("%d", &totChrges);
printf("\nEnter Total Credit: ");
scanf("%d", &totCrdtd);
printf("\nEnter Credit Limit: ");
scanf("%d", &crdtLmt);
}
/* LOST TO AS WHERE TO PUT THIS */
//if (totCrdtBall > crdtLmt)
//{
// printf("\nYou have Exceeded your Credit Limit");
//}
printf("\nThe Customer Account Number is: %d\n", acctNum);
printf("\nThe Customer Credit Limit is: %d\n", crdtLmt);
printf("\nThe Customer Credit Ballance is: %d\n", totCrdtd);
getch();
return 0;
}



LinkBack URL
About LinkBacks


