All pastes #137118 Raw Edit

Scott

public cpp v1 · immutable
#137118 ·published 2006-08-18 04:17 UTC
rendered paste body
#include <iomanip.h>#include <fstream.h>#define CLS cin.ignore(cin.rdbuf()->in_avail())int Input(ofstream& ShirtsW, int Quantity[4], float Price[4], int ID[4])  { int Count;    for (Count=0; Count<=4; Count++)      { CLS; cout<<"\nPlease enter Shirt ID: "; cin>>ID[Count];        CLS; cout<<"\nPlease enter Shirt Price: "; cin>>Price[Count];        CLS; cout<<"\nPlease enter Shirt Quantity: "; cin>>Quantity[Count];        ShirtsW<<ID[Count]<<" "<<Price[Count]<<" "<<Quantity[Count]<<endl;      }    return 0;  }    int Read(ifstream& ShirtsR, int Quantity[4], float Price[4], int ID[4])  { int Count;    cout.setf(ios::fixed, ios::floatfield);    cout.setf(ios::showpoint);    cout<<setprecision(2);    cout<<"\n"<<setw(7)<<"ID"<<"\tPrices\tQuantity";    cout<<"\n"<<setw(7)<<"--"<<"\t------\t--------";    for (Count=0; Count<=4; Count++)      { ShirtsR>>ID[Count]>>Price[Count]>>Quantity[Count];        cout<<"\n"<<setw(7)<<ID[Count]<<"\t"<<setw(6)<<Price[Count]<<"\t"<<setw(8)<<Quantity[Count];              }    return 0;  }       int Calc(int Quantity[4], float Price[4], int ID[4])  { int Count;    cout.setf(ios::fixed, ios::floatfield);    cout.setf(ios::showpoint);    cout<<setprecision(2);    cout<<"\n"<<setw(7)<<"ID"<<"\tPrices\tQuantity\tTotal Sale Amount";    cout<<"\n"<<setw(7)<<"--"<<"\t------\t--------\t-----------------";    for (Count=0; Count<=4; Count++)      { float TotalAmount=Quantity[Count]*Price[Count];        cout<<"\n"<<setw(7)<<ID[Count]<<"\t"<<setw(6)<<Price[Count]<<"\t"<<setw(8)<<Quantity[Count]<<"\t"<<setw(17)<<TotalAmount;       }    return 0;  }int Total(int Quantity[4], float Price[4], int ID[4])  { int TotalQuantity=0;    float TotalSales=0;    int Count;          for (Count=0; Count<=4; Count++)      { TotalQuantity=TotalQuantity+Quantity[Count];        TotalSales=TotalSales+Price[Count]*Quantity[Count];        }    cout<<"\nTotal Quantity of all shirts sold = "<<TotalQuantity;    cout<<"\nTotal Sales of all shirts sold = $"<<TotalSales;    return 0;  } int IDCheck(int ID[4])  { int TestID;    cout<<"\nPlease enter ID of shirt desired: "; cin>>TestID;    if (TestID==ID[0]&&TestID==ID[1]&&TestID==ID[2]&&TestID==ID[3]&&TestID==ID[4]) cout<<"\nShirt ID exists in array.";    else cout<<"\nShirt ID does not exist in array.";    return 0;  }      int Highest(float Price[4])   { int Count;    float HighestPrice=0;    for (Count=0; Count<=4; Count++)      { if (Price[Count]>=HighestPrice) HighestPrice=Price[Count];      }    cout<<"\nHighest Priced Shirt = $"<<HighestPrice;      return 0;  }  int Lowest(float Price[4])  { int Count;    float LowestPrice=Price[0];    for (Count=0; Count<=4; Count++)      { if (Price[Count]<=LowestPrice) LowestPrice=Price[Count];      }    cout<<"\nLowest Priced Shirt = $"<<LowestPrice;           return 0;  }        int main()  { int Quantity[4];    float Price[4];    int ID[4];    ofstream ShirtsW("Shirts.dat");    Input(ShirtsW, Quantity, Price, ID);    ShirtsW.close();    ifstream ShirtsR("Shirts.dat");    Read(ShirtsR, Quantity, Price, ID);    ShirtsR.close();    Calc(Quantity, Price, ID);    Total(Quantity, Price, ID);    IDCheck(ID);    Highest(Price);    Lowest(Price);    cin>>ID[4];    return 0;  }