Answer:
See explaination
Step-by-step explanation:
#include<iostream>
#include<fstream>
using namespace std;
int main(){
double price, totalPrice = 0, weight;
string product, filename;
cout<<"Enter filename: ";
cin>>filename;
ifstream fin;
fin.open(filename.c_str());
while(fin>>product>>price){
cout<<"Enter weight for "<<product<<": ";
cin>>weight;
totalPrice+=price*weight;
}
cout<<"\\The total cost of the purchase: $"<<totalPrice<<endl;
return 0;
}