Posted by: Robert Frost October 27, 2004
Login in to Rate this Post:
0
?
Why is nobody listening to me????
SAJHA DEBUGGERS HELP WANTED>>>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Here is the program and below I have listed the errors that I am not being able to fix...I need your help, just asked for the Prof. for more time on this project..so please help me..
#include
int pennies, nickels, dimes, quarters;
int main()
{
char y;
int p,n,d,q;
pennies=0;
nickels=0;
dimes=0;
quarters=0;
display(pennies,nickels,dimes,quarters);
do {
printf("Select an action:: (I/R/D/Q) \n");
printf("I = Insert, R = Remove, D = Display, Q = Quit");
scanf("%c", &y);
if y = "I"
{
printf("Insert..");
scanf("%d%d%d%d", &p, &n, &d, &q);
insert(p,n,d,q);
display(pennies,nickels,dimes,quarters);
}
else if y = "R"
{
printf("Remove..");
scanf("%d%d%d%d", &p, &n, &d, &q);
rem(p,n,d,q);
display(pennies,nickels,dimes,quarters);
}
else if y = "D"
{
display(pennies,nickels,dimes,quarters);
}
while(y != "Q");
{
printf("Program terminated...");
}
}
//Function that inserts money in the purse
int insert(int p, int n, int d, int q)
{
pennies += p;
nickels += n;
dimes += d;
quarters += q;
}
//Function that displays the contents of the purse
int display(int pnys, int nkls,int dimes, int qrts)
{
float x = pnys + 5*nkls + 10*dimes + 25*qrts;
x = (float)x/100;
printf("Contents of your purse : \n");
printf( " %d quarters + %d dimes + %d nickels + %d pennies = $%d \n", qrts, dimes, nkls, pnys, x);
}
//Function that removes money from the purse
int rem(int p,int n, int d,int q)
{
pennies -= p;
nickels -= n;
dimes -= d;
quarters -= q;
}
Errors that are showing:
pndq.c: In function `main':
pndq.c:23: parse error before "y"
pndq.c:30: parse error before "else"
pndq.c: At top level:
pndq.c:37: parse error before "else"