Billing System program

Sep 2, 2011 at 10:37am
i was wondering the program i made was wrong but still i can run it.

my program does not undergo throught the if else statement.
can you also suggest me some tips on how to make my program be easy and be runnable.

here's my program:

#include "stdafx.h"
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
char cont=0,cust_name[20],item_code[3];
float quantity,amount,total,change;

int cust_no;

while(cont!='N' || cont!='n')
{
cout<<"Billing System"<<endl;
cout<<"Input Customer Number :";
cin>>cust_no;
cout<<"\nInput Customer Name :";
cin>>cust_name;
cout<<"\nInput Item Code :";
cin>>item_code;
cout<<"\nInput Quantity :";
cin>>quantity;
cout<<"\nInput Amount Tendered :";
cin>>amount;
cout<<endl;


if (item_code=="AB1")
{ cout<<"Hi "<<cust_name<<"!"<<endl;
total=10*quantity;
cout<<"Your total bill is "<<total<<endl;}


else if (item_code=="AB2")
{cout<<"Hi "<<cust_name<<"!"<<endl;
total=30*quantity;
cout<<"Your total bill is "<<total<<endl;
}


else if (item_code=="AB3")
{cout<<"Hi "<<cust_name<<"!"<<endl;
total=25*quantity;
cout<<"Your total bill is "<<total<<endl;}


else if (item_code=="AB4")
{cout<<"Hi "<<cust_name<<"!"<<endl;
total=120*quantity;
cout<<"Your total bill is "<<total<<endl;}


else if (item_code=="AB5")
{cout<<"Hi "<<cust_name<<"!"<<endl;
total=65*quantity;
cout<<"Your total bill is "<<total<<endl;
}


else if(total>amount)
cout<<"You do not have enough money to buy the item"<<endl;
else
cout<<"Your change is "<<amount-total<<endl;




cout<<"Do you want to continue?: Y/N";
cin>>cont;


}




system("pause>p");
return 0;



}
Sep 2, 2011 at 12:31pm
Change your while statement to this:

1
2
3

while( cont != 'N' && cont != 'n' )
Topic archived. No new replies allowed.