Sory for asking too much about this..But I really need to solve this problem immendiately..
This is just simple,but i dont know why i cant finf whats wrong with my code..
I'm trying to display the price,sale and the to total sale in point form..
like this :
TOTAL SALE : $20.00
but now i can only display it in single number without the point..
i already declared it as double but i dont know why its not working..
This is the only thing left for my program to work successfully..
Below is my code...
Thank you for helping :)really need your help.....
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
struct record{
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');
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;
}
cout<<endl;
int total = 0;
for(int counter=0; counter < i; counter++)
{
total += product[counter].sale;
}
cout<<"TOTAL SALE IS:"<<total;
cout<<endl;
double payment;
cout<<"PLEASE ENTER THE PAYMENT RECEIVED :";
cin>>payment;
while (payment<total){
cout<<"The Amount Of Payment Is Unsufficient !";
cout<<"PLEASE ENTER THE PAYMENT RECEIVED :";
cin>>payment;
}
cout<<endl;
cout<<"TOTAL SALE :$"<<total<<endl;
cout<<"RECEIVE PAYMENT :$"<<payment<<endl;
cout<<"BALANCE :$"<<payment-total<<endl;
cin.get();
}