Hello!
I have written the code for a function that takes an object DailySale and compares its values with an array of objects fromInventory. If the id of the DailySale object matches with the id of an object in the array, it takes the price from there and calculates the total cost. I am getting garbage numbers in result. Here is the code
of the function:
int computeTotalPrice(Medicine FromInventory[], Sale DailySale){
int TotalPrice;
int Price;
for (int l=0;l<3;l++){
if(DailySale.getId()==FromInventory[l].getId()){
Price= FromInventory[l].getUnitPrice();
}
And in the main i am calling this function in a loop
for(int j=0;j<3;j++){
cout<<endl<<endl;
DailySale[j].dailySaleReport();
cout<<endl;
computeTotalPrice(MedicineList,DailySale[j]) ;
I want to to know what is wrong with the logic in the loop.
Another problem i am facing is that i take name as input from the user in an char InpuName[10], and i set this name as my sale's object's name by using setName function. When i display the name, it does not diplay anything. The code is as follows
char InputName[10];
cin>>InputName;
setName(InputName);
But when i display the name, nothing gets printed
cout<<"Name of the item sold"<<endl<<Name<<endl;
Help me solve these two problems. I tried to take user input in char *InputName, but then the program stops in the middle of execution.