reading_from_file3

reading_from_file3 - infile>> bookShipping infile.close...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // reading from file #include <fstream> // to read from files or write to files #include <iostream> // cin, cout using namespace std int main() { double pricePerBook = 0.0 d double bookShipping = 0.0 int numBooks = 0 double totalPrice = 0.0 ifstream infile("C:/Temp/a3data.txt") // or // ifstream infile // infile.open("C:/Temp/a3data.txt") infile >> pricePerBook
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: infile >> bookShipping infile.close() cout << "How many books? " cin >> numBooks double bookSubtotal = pricePerBook * numBooks + bookShipping * numBooks cout << bookSubtotal << endl ofstream outfile("C:/Temp/output.txt", ios::app) // append mode outfile << bookSubtotal << endl outfile.close() return 0 }...
View Full Document

This note was uploaded on 04/01/2008 for the course CMPSC 101 taught by Professor Drobish,renee during the Spring '07 term at Penn State.

Ask a homework question - tutors are online