Hi..
This is my program for my assignment..
So far,I've succeeded in coding the program but not for the last part..
I still need to find the total sale for this program...
and the result at the end suppose to be more or less like this :
Total sale : $25.00
Payment : $50.00
Balance : $25.00
I've tried so hard,but still i cant find the right way to do it..
So i hope you all could me....
Thank You..:)
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
class record{
public :
string id;
string name;
double price;
double quantity;
double sale;
};
record product[100];
int i=0;
char answer;
cout<<"--------------------------------------------------------------------------------";
cout<<"\t\t\t\tCASH RECEIPT PROGRAM"<<endl;
cout<<"--------------------------------------------------------------------------------";
cout<<endl;
do{
cout << "Enter the Product ID : ";
cin >> product[i].id;
cout << "Enter the Product Name : ";
cin >> product[i].name;
cout << "Enter the Price For Single Item : ";
cin >> product[i].price;
cout << "Enter The Quantity : ";
cin >> product[i].quantity;
cout<<endl;
cout << "Would You like to enter another product? (Y/N) ";
cin >> answer;
i++;
cout<<endl;
}while(answer == 'y' || answer == 'Y' && answer !='N'&&'n');
if (answer == 'N' || 'n'){
int index;
cout<<"--------------------------------------------------------------------------------";
cout<<"ID |"<<setw(13)<<"ITEM |"<<setw(12)<<"PRICE |"<<setw(10)<<"QTY |"<<setw(10)<<"SALE"<<endl;
cout<<"--------------------------------------------------------------------------------";
for(index=0; index<i; index++){
product[index].sale=(product[index].price)*(product[index].quantity);
// Display all the info about that product
cout <<product[index].id<<setw(10)<<product[index].name<<setw(10)<<"$"<<product[index].price<<setw(10)
<<product[index].quantity<<setw(10)<<product[index].sale;
cout<<endl;
}
}
cin.get();
}