gold - //if no error occurred while opening file { //input...

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

View Full Document Right Arrow Icon
// gold.cpp / #include <iostream.h> #include <iomanip.h> #include <fstream.h> #include "apvector.h" # int main() { float x; int index; i ifstream infile_us; //declare file pointer for us information ifstream infile_japan; //declare file pointer for japan information ifstream infile_germany; //declare file pointer for germany information ifstream infile_uk; //declare file pointer for uk information / apvector <float> us(10); //declare a vector names US with 10 elements apvector <float> japan(10); apvector <float> germany(10); apvector <float> uk(10);"us.dat",ios::in); //open the us file for input"japan.dat",ios::in); //open the japan file for input"germany.dat",ios::in); //open the germany file for input"uk.dat",ios::in); //open the uk file for input / if (infile_us && infile_japan && infile_germany && infile_uk)
Background image of page 1

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

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

Unformatted text preview: //if no error occurred while opening file { //input data from file { for (index=0;index&lt;=9;index++) { infile_us &gt;&gt; x; us[index]=x; u infile_japan &gt;&gt; x; japan[index]=x; j infile_germany &gt;&gt; x; germany[index]=x; g infile_uk &gt;&gt; x; uk[index]=x; u } } else { cout &lt;&lt; &quot;An error occurred while opening this file.\n&quot;; } cout.setf(ios::showpoint); cout.setf(ios::fixed); cout &lt;&lt; setprecision(2); cout &lt;&lt; &quot;YEAR&quot; &lt;&lt; &quot; &quot; &lt;&lt; setw(10) &lt;&lt; &quot;US&quot; &lt;&lt; setw(10) &lt;&lt; &quot;JAPAN&quot; &lt;&lt; setw(10) &lt;&lt; &quot;GERMANY&quot; &lt;&lt; setw(10) &lt;&lt; &quot;UK&quot; &lt;&lt; endl; for (index=0;index&lt;=9;index++) { cout &lt;&lt; 1980+index &lt;&lt; &quot; &quot; &lt;&lt; setw(10) &lt;&lt; us[index] &lt;&lt; setw(10) &lt;&lt; japan[index] &lt;&lt; setw(10) &lt;&lt; germany[index] &lt;&lt; setw(10) &lt;&lt; uk[index] &lt;&lt; endl; } infile_us.close(); infile_japan.close(); infile_germany.close(); infile_uk.close(); return 0; }...
View Full Document

Page1 / 2

gold - //if no error occurred while opening file { //input...

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