IF YOU DO NOT READ THE INSTRUCTIONS HERE DO NOT ANSWER..... READ THE QUESTION BE
ID: 3770396 • Letter: I
Question
IF YOU DO NOT READ THE INSTRUCTIONS HERE DO NOT ANSWER..... READ THE QUESTION BEFORE YOU ANSWER AND I ONLY WANT ANSWERS THAT ARE TO THIS QUESTION ONLY!!!!!!!!!Create pseudocode and C++ code for a program that displays the inventory of your goofy gift shop. The inventory is in a file called lab10.txt. The file contains 3 fields for each record: 1.Item name. 2.Quantity in inventory. 3.Item price. Your program will display the contents of the file in tihree columns labeled “Name”, “Quantity”, and “Price”. Your program will display a forth column of data labeled “Value” that will be the quantity * price for each inventory item. Your program does not know how many items are in inventory, so it should read until there are no more records. Your program will have a value returning function used to calculate the value for each item in inventory. It will take as input the quantity and price of an item and will return the value of that item.
lab10.txt
Han Solo in Carbonite Rug
27 units
62.99
Shark Plush Slippers for Grown Ups
35 units
24.99
Halo 4 USNC Messenger Bags
41 units
79.99
Star Wars Automotive Floor Mats
12 units
39.99
Batman Diaper Bag
10 units
34.99
Star Trek TNG Uniform Bodysuits
58 units
19.99
The Walking Dead Monopoly
17 units
39.99
Explanation / Answer
Here is the solution for you. If you have any further queries, just get back to me.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
double getAmount(int a, double b)
{
return a * b;
}
int main()
{
ifstream file;
file.open("Inventory.txt");
string name, temp;
int quantity;
double price;
cout<<setw(40)<<"Name"<<setw(10)<<"Quantity"<<setw(6)<<"Price"<<"Value"<<endl;
while(!file.eof())
{
getline(file, name);
file>>quantity;
file>>temp;
file>>price;
file.ignore();
cout<<setw(40)<<name<<setw(10)<<quantity<<setw(6)<<fixed<<setprecision(2)<<price<<setw(10)<<fixed<<setprecision(2)<<getAmount(quantity, price)<<endl;
}
}