This is the spec's for this project Acme Lumber Company wants a program that will store the SPECIES of wood they sell and the price that they sell it for into to a text file called HARDWOOD.TXT.
Write a program that prompts the user for the name of a type of wood, and the current selling price for the wood. The program will then write the specified information into the HARDWOOD.TXT file, replacing the existing file.
The format of the file called HARDWOOD.TXT is:
SPECIES,PRICE
Where SPECIES is the name of the wood. For example: OAK
and PRICE is the price of the wood per board foot. For example: 2.43
Code:
// This program will prompt the user for the name of a type of wood,
// and will output the current selling price for the wood.
///////////////////////////////////////////////////////////////////////////////
// Include Files //////////////////////////////////////////////////////////////
#include <fstream.h>
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
// Function Prototypes ////////////////////////////////////////////////////////
// Program Mainline ///////////////////////////////////////////////////////////
int main( )
{
char specis[64];
double price;
//Get data from user
cout << "Enter hardwood name:" << endl;
cin.getline( hardwood, sizeof( hardwood ) );
cin >>
//read data from file
ifstream fin( "hardwood.txt" );
ofstream fout("hardwood.txt")
if (fin,fail) {
fout << "File " << "hardwood.txt" << " not found!";
getch();
return 1;
}//endif
getch();
return 1;
}//endmn
fout << hardwood << "\t" << price << "Above data written to "hardwood.txt" << endl;
fin.getline( hardwood, sizeof( hardwood ), "\t" );
fin >> hardwood;
getch();
return 0;
}//endmn