// reading from a file and writing to a file in append mode #include #include using namespace std; int main() { double pricePerBook = 0.0; int numBooks = 0; double totalPrice = 0.0; ifstream infile("C:/Documents and Settings/PSU_USERNAME/Desktop/data.txt"); infile >> pricePerBook; infile.close(); cout << "How many books? "; cin >> numBooks; double bookSubtotal = pricePerBook * numBooks; cout << "Your total price is $" << bookSubtotal << endl; ofstream outfile("C:/Documents and Settings/PSU_USERNAME/Desktop/output.txt", ios::app); // append mode outfile << bookSubtotal << endl; outfile.close(); return 0; }// end of main