solutions17 - CSCI-1100 Computer Science I Rensselaer...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCI-1100 Computer Science I Rensselaer Polytechnic Institute Spring 2004 Studio 17 -- Solutions Part 1 #include <fstream> #include <string> #include <iomanip> #include <iostream> using namespace std; int main () //PURPOSE: compute percentage of stock value change //PRECONDITIONS: input data file in project folder with // stock name, opening price, and closing price //POSTCONDITIONS: creates output file in project folder // with stock name, opening price, closing price, and // percentage change for the day { ifstream infile; // Input file ofstream outfile; // Output file string stockname; // Stock name for identification float openprice; // Opening stock price float closeprice; // Closing stock price float percent; // Percentage gain or loss // open the files infile.open("stock.txt"); outfile.open("report.txt"); // write numbers in output file with 2 decimal places outfile << setiosflags(ios::fixed) << setprecision(2); // loop until there is no more data in input file // read data for first stock from input file
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

solutions17 - CSCI-1100 Computer Science I Rensselaer...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online