I do not know how to use the debugger and I think thad I do not have one So I am trying to create simply linked list in c++ Called Product this list will be used to store product... and I have already made a function that add a new node to the begining of the list and also made a void function called "Afficher1" that is supposed to show me the total number of products in the list and their total price EXCLUDING VAT and the total amount of VAT and finnaly TOTAL Including VAT but when I call the void in the main function it does not run it just finishesh the main execution with a return value !=0
and when I remove some operations that are inside the function such as:
double total_TVA=((total)*(temp->TVA))/(100.0); double TTC=total+total_TVA;
#include<iostream>
#include<string>
using namespace std;
struct Product{
string code_prod;
string designation;
string UM;
double PUA_HT;
double QTE;
double TVA;
Product *next;
};
Product *head=NULL;
Product *Add_Product(Product* &head, string code, string des, string um, double pua, double qte, double tva){
Product *prod=new Product;
prod->code_prod=code;
prod->designation=des;
prod->UM=um;
prod->PUA_HT=pua;
prod->QTE=qte;
prod->TVA=tva;
prod->next=head;
head=prod;
return head;
}
void Afficher1(){
if(head != NULL){
Product *temp=head;
double total=0;
int i=0;
while(temp != NULL){
total=total + ((temp->PUA_HT)*(temp->QTE));
i++;
temp=temp->next;
}
double total_TVA=((total)*(temp->TVA))/(100.0);
double TTC=total+total_TVA;
cout<<"Nombre total des produits Achetes: "<<i<<endl;
cout<<"Le Montant Total HT: "<<total<<endl;
cout<<"Total TVA de "<<temp->TVA<<" : "<<total_TVA<<endl;
cout<<"Total TTC: "<<TTC<<endl;
}
}
int main(){
Product *head=NULL;
string codes; string dess; string ums; double puas; double qtes; double tvas;
for(int i=0;i<1;i++){
cout<<"Donner les infos pour le proudit "<<i+1<<endl;
cin>>codes;
cin>>dess;
cin>>ums;
cin>>puas;
cin>>qtes;
cin>>tvas;
head=Add_Product(head, codes, dess, ums, puas, qtes, tvas);
}
Afficher1();
return 0;
}