Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please give me a simple code to make this happen in C++. Thanks! Prompt the user

ID: 3788666 • Letter: P

Question

Please give me a simple code to make this happen in C++. Thanks!

Prompt the user for the name of the file containing the list of items for auction: Open the file and process the following for each item in the file: Name - a string that may contain blanks ex:"Chinese Vase with Green Elephant decor" Time a string that does not contain blanks ex: 07:10:36 Price - a floating point value. ex: 38.99 Examine the structure of the data by opening, and examining the content of the sample input files provided. Determine and display the following information: Total Number of all items up for auction - an integer value Highest and Lowest Cost found amongst these items - floating point values. Average Cost of all items - floating point value. (price sum/number items) Rounded Average Cost of all items - an integer value. (round average found above) WebAdd Points - floating point value (calc with formula below) WebAddPoints = number of items + ( squareroot Average Price/DONATION WEBADD)^3 WebAddPoints is a value calculated with the formula above, and using DONATION and WEBAD which are constant values declared in the provided code template. You must use the math functions pow and squareroot for the above formula. If there is only one item in the items file, then the WebAddPoints is equal to zero.

Explanation / Answer

Here is the code for you:

#include <iostream>
#include <fstream>
#include <cmath>
#define DONATION 20
#define WEBADD 10
using namespace std;
int main()
{
string fileName;
cout<<"Enter the name of the file: ";
cin>>fileName;
ifstream fin;
fin.open(fileName);
string name, time;
double price, highestCost, lowestCost, avgCost, webAddPoints;
int numOfItems = 0, roundedAvgCost;
while(!fin.eof())
{
fin>>name;
fin>>time;
fin>>price;
if(numOfItems == 0)
highestCost = lowestCost = avgCost = price;
if(price > highestCost)
highestCost = price;
if(price < lowestCost)
lowestCost = price;
avgCost += price;   
numOfItems++;
}
avgCost /= numOfItems;
if(numOfItems == 1)
webAddPoints = 0;
else
webAddPoints = numOfItems + pow((sqrt(avgCost / (DONATION + WEBADD))), 3);
cout<<"Total number of all items up for auction: "<<numOfItems<<endl;
cout<<"Highest cost found is: "<<highestCost<<endl;
cout<<"Lowest cost found is: "<<lowestCost<<endl;
cout<<"Average cost of all items: "<<avgCost<<endl;
cout<<"Rounded average cost of all items: "<<(int)avgCost<<endl;
cout<<"WebAdd Points: "<<webAddPoints<<endl;
}