1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#include <iostream>
#include <string>
#include <fstream> // Used to output into a text file
#include <iomanip>
using namespace std;
struct programParts
{
string partNumber;
string partName;
char partClass;
int numStock;
double unitPrice;
};
void writeOut(string number, string name, char c, int stock, double price);// Function Prototype
int main()
{
// Variables needed
string number;
string name;
char c;
int stock;
double price;
char choice;
do
{
cout << "Enter part information (part number, name, class, on hand balance and price):" << endl;
cin >> number >> name >> c >> stock >> price;
programParts details;
writeOut(number, name, c, stock, price);
cout << "More parts? (y/n)" << endl;
cin >> choice;
}
while (choice == 'y'); // User input, continues the loop
cout << "Goodbye!" << endl;
}
void writeOut(string number, string name, char c, int stock, double price)
{
ofstream fout("out.txt");
fout << number << " " << name << " " << c << " " << stock << " " << price << endl;
}
|