This post has been edited by Kcbroncofan: 05 October 2005 - 06:03 PM
Storing Data to a File
Page 1 of 15 Replies - 1105 Views - Last Post: 05 October 2005 - 07:56 PM
#1
Storing Data to a File
Posted 05 October 2005 - 04:29 PM
I have an assignment due. The assignment asks to calculate the property tax. I already got this code done. I need to put this in a file. How do I get data into a file. Then I need to put the file into program and then get the file to open.
Replies To: Storing Data to a File
#3
Re: Storing Data to a File
Posted 05 October 2005 - 07:05 PM
This is what I have so far:
I am not sure what I need to do next.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
double aval;
double proptaxamt;
double trate = 1.05;
double proptax;
int main()
{
cout << "Enter the assesed value of the property. $";
cin >> aval;
ifstream inData;
ofstream outData;
inData.open("prog.dat");
outData.open("prog.out");
proptaxamt = aval * 0.92;
proptax = proptaxamt * trate / 100;
cout << fixed << showpoint;
cout << "Assessed Value: " << setprecision(2) << aval << endl;
cout << "Taxable Amount: " << proptaxamt << endl;
cout << "Tax Rate for each $100.00: " << trate << endl;
cout << "Property Tax: " << proptax << endl;
inData.close();
outData.close();
return 0;
}
I am not sure what I need to do next.
#4
Re: Storing Data to a File
Posted 05 October 2005 - 07:25 PM
What specific things need to go into the file, and when do they need to go there
and likewise what specific things need to be read from the file, where do they need to go and when does that need to happen
and likewise what specific things need to be read from the file, where do they need to go and when does that need to happen
#5
Re: Storing Data to a File
Posted 05 October 2005 - 07:51 PM
This is what needs to be in the file:
cout << fixed << showpoint;
cout << "Assessed Value: " << setprecision(2) << aval << endl;
cout << "Taxable Amount: " << proptaxamt << endl;
cout << "Tax Rate for each $100.00: " << trate << endl;
cout << "Property Tax: " << proptax << endl;
cout << fixed << showpoint;
cout << "Assessed Value: " << setprecision(2) << aval << endl;
cout << "Taxable Amount: " << proptaxamt << endl;
cout << "Tax Rate for each $100.00: " << trate << endl;
cout << "Property Tax: " << proptax << endl;
#6
Re: Storing Data to a File
Posted 05 October 2005 - 07:56 PM
ah
the object cout direct what is put into it by << to the screen
likewise you defined file objects
ifstream inData;
ofstream outData;
the ofstream outData is a file output object, that works the exact same way as cout
just duplicate or replace cout with outData.
the object cout direct what is put into it by << to the screen
likewise you defined file objects
ifstream inData;
ofstream outData;
the ofstream outData is a file output object, that works the exact same way as cout
just duplicate or replace cout with outData.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|