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

#include<iostream> #include<iomanip> #include<fstream> using namespace std; //Gl

ID: 3538447 • Letter: #

Question

#include<iostream>

#include<iomanip>

#include<fstream>


  

using namespace std;

//Global variables

ifstream fin;

ofstream fout;

//FN Prototypes


void headerfn();//void FN without parameters

void inputfn (string tool[25], int quantity[25], float price[25], int&counter);

void outputfn(string tool[25], int quantity[25], float price[25], float&value, int counter);

float calcfn(int quantity[25], float price[25], float value[25], int counter);


int main(){

system("Color F0");

  

fin.open("tools.txt");

while (!fin){

cout<<"File Error"<<endl;

system ("Pause");

return 1;}

  

//Calling void FN without parameters

headerfn();

  

string tool[25];

int quantity[25];

float price[25];

int counter;

float value;


inputfn(tool, quantity, price, counter);

calcfn(quantity, price, value, counter);

outputfn(tool, quantity, price, value, counter);

cout<<endl;

system("Pause");

return 0;

  

  

}//End of main



//FUNCTION, FUNCTIONS, FUNCTIONS


//******************************************************************************

//void FN without parameters

void headerfn(){

cout<<"******************************************* ";

cout<<"* C++ * ";

cout<<"* * ";

cout<<"* * ";

cout<<"* Arrays * ";

cout<<"******************************************* ";

}//End of void FN without parameters


//******************************************************************************

void inputfn (string tool[25], int quantity[25], float price[25], int&counter){

counter=0;

while (fin&&counter<25){

fin>>tool[counter]>>quantity[counter]>>price[counter];

counter++;

if (fin.peek()==' ')fin.ignore();}

cout<<"The current Count is: "<<counter<<endl<<endl;

  

}

float calcfn(int quantity[25], float price[25], float value[row], int counter){

float value;

for (int row=0;row,counter;row++){

value[row]=quantity[row]*price[row];}

return value;

}

  

void outputfn(string tool[25], int quantity[25], float price[25], float value[25], int counter){

cout<<left;

cout<<setw(15)<<"Tools"

<<setw(15)<<"Quantities"

<<setw(15)<<"Prices"<<endl<<endl;

cout<<fixed<<showpoint<<setprecision(2);

for (int row=0;row<counter;row++){

cout<<setw(15)<<tool[row]

<<setw(15)<<quantity[row]

<<setw(15)<<price[row]

<<setw(15)<<value<<endl;}

}



Can someone please get this to work??

Explanation / Answer

#include<iostream>

#include<iomanip>

#include<fstream>


  

using namespace std;

//Global variables

ifstream fin;

ofstream fout;

//FN Prototypes


void headerfn();//void FN without parameters

void inputfn (string tool[], int quantity[], float price[], int& counter);

void outputfn(string tool[], int quantity[], float price[], float value[], int& counter);

void calcfn(int quantity[], float price[], float value[], int& counter);


int main(){

system("Color F0");

  

fin.open("tools.txt");

while (!fin){

cout<<"File Error"<<endl;

system ("Pause");

return 1;}

  

//Calling void FN without parameters

headerfn();

  

string tool[25];

int quantity[25];

float price[25];

int counter;

float value[25];


inputfn(tool, quantity, price, counter);

calcfn(quantity, price, value, counter);

outputfn(tool, quantity, price, value, counter);

cout<<endl;

system("Pause");

return 0;

  

  

}//End of main



//FUNCTION, FUNCTIONS, FUNCTIONS


//******************************************************************************

//void FN without parameters

void headerfn(){

cout<<"******************************************* ";

cout<<"* C++ * ";

cout<<"* * ";

cout<<"* * ";

cout<<"* Arrays * ";

cout<<"******************************************* ";

}//End of void FN without parameters


//******************************************************************************

void inputfn (string tool[], int quantity[], float price[], int& counter){

counter=0;

while (fin && counter<25){

fin>>tool[counter]>>quantity[counter]>>price[counter];

counter++;

if (fin.peek()==' ')fin.ignore();}

cout<<"The current Count is: "<<counter<<endl<<endl;

  

}

void calcfn(int quantity[], float price[], float value[], int& counter){

  

for (int row=0;row<counter;row++){

value[row]=quantity[row]*price[row];}

  

}

  

void outputfn(string tool[], int quantity[], float price[], float value[], int& counter){

cout<<left;

cout<<setw(15)<<"Tools"

<<setw(15)<<"Quantities"

<<setw(15)<<"Prices"

<<setw(15)<<"Values"<<endl<<endl;

cout<<fixed<<showpoint<<setprecision(2);

for (int row=0;row<counter;row++){

cout<<setw(15)<<tool[row]

<<setw(15)<<quantity[row]

<<setw(15)<<price[row]

<<setw(15)<<value[row]<<endl;}

}