In: Physics
(IN C++)A special tax regulation allows an employee to set aside
earnings to pay for qualified medical expenses and other items.
At LocalPharm, a privately owned pharmacy, codes are assigned to
each product If the code starts with an 'C', 'D', or 'H', the item
is eligible for reimbursement. Otherwise, the product is not.
Write a program that inputs the records contained within a file
listing LocalPharm’s inventory. Each record contains an inventory
code, an item description, and a cost. Your program should output a
list of all inventory items. For items that are eligible for
reimbursement, the term “Qualified Expense” should appear next to
the item in your output.
A sample input file might look like this:
A1010 Strawberry Shampoo 7.99 C3940 Liquid Vitamins 10.12 C9304
Diaper Rash Cream 6.58 C9854 Cleansing Wipes 4.15 D2901 Nutritional
Chocolate Shake 8.00 F3743 Flashlight 6.21 F4484 Dryer Clothes 4.20
G3384 Smile Toothpaste 3.93 H1192 Bath Bench 51.53 H2324 Blood
Pressure Monitor 34.61 Z3445 Rejuvenating Serum 19.74
Note: Could you plz go through this code and let me know if u
need any changes in this.Thank You
=================================
// pharmacyProds.txt (Input file)
A1010 Strawberry Shampoo 7.99
C3940 Liquid Vitamins 10.12
C9304 Diaper Rash Cream 6.58
C9854 Cleansing Wipes 4.15
D2901 Nutritional Chocolate Shake 8.00
F3743 Flashlight 6.21
F4484 Dryer Clothes 4.20
G3384 Smile Toothpaste 3.93
H1192 Bath Bench 51.53
H2324 Blood Pressure Monitor 34.61
Z3445 Rejuvenating Serum 19.74
==============================
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
using namespace std;
int findSeperatorIndex(string str);
int main() {
//Declaring variables
ifstream dataIn;
string code;
int index;
string name;
double price;
string str;
dataIn.open("pharmacyProds.txt");
//checking whether the file name is valid or not
if(dataIn.fail())
{
cout<<"* File Not Found *";
return 1;
}
else
{
//Reading the data from the file
while(getline(dataIn,str))
{
index=str.find(" ");
code=str.substr(0,index);
str=str.substr(index+1,str.length()-1);
if(str.at(0)=='C' || str.at(0)=='D' || str.at(0)=='H')
{
cout<<code<<" "<<str<<" -- Qualified
Expense"<<endl;
}
else
{
cout<<code<<" "<<str<<endl;
}
}
dataIn.close();
}
return 0;
}
==================================
Output:
PLEASE LIKE MY ANSWER