Below is my output followed by the code:
Computer Systems Society Kim Cares 49 3675.00
Society of Women Engineers Jeanie Queen 51 3825.00
Sigma Tau Gamma Storm Drain 241 18075.00
Trekkies C. Kirk 230 17250.00
Home Brewers Ross Coe 15 1125.00
High Altitude Ballooning Justin Time 19 1425.00
Rugby Ryan Johns 25 1875.00
IEEE Marc Bansmere 36 2700.00
International Club Kong Mbonkum 102 7650.00
Dance Club Will Shaver 64 4800.00
0 0.00
╠╠╠╠╠╠╠╠
Society of Women Engineers -858993460-64424509440.00
╠╠╠╠╠╠╠╠
Sigma Tau Gamma 3748896281167200.00╫ ╠╠╠╠╠╠╠╠
Trekkies -858993460-64424509440.00 ╠╠╠╠╠╠╠╠
Home Brewers -858993460-64424509440.00 ╠╠╠╠╠╠╠╠
High Altitude Ballooning -858993460-64424509440.00
╠╠╠╠╠╠╠╠
Rugby -858993460-64424509440.00 ╠╠╠╠╠╠╠╠
IEEE -858993460-64424509440.00 ╠╠╠╠╠╠╠╠
International Club -858993460-64424509440.00 ╠╠
╠╠╠╠╠╠
Dance Club -858993460-64424509440.00Press any key to continue . . .
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstring>
using std::cin;
using std::cout;
using std::endl;
using std::fixed;
using std::right;
using std::left;
using std::setw;
using std::setprecision;
using std::ifstream;
using std::ofstream;
const float MONEY = 75.00;
int main()
{
ifstream infile( "data.txt" );
char clubname[10][70];
char presname[10][70];
char numofmems[10][70];
int number[10];
int i = 0;
if ( infile.is_open() )
{
infile.getline(clubname[i], 70, ',');
infile.getline(presname[i], 70, ',');
infile.getline(numofmems[i], 70, ',');
number[i] = atoi(numofmems[i]);
while ( !infile.eof() )
{
++i;
infile.getline(clubname[i], 70, ',');
infile.getline(presname[i], 70, ',');
infile.getline(numofmems[i], 70, ',');
number[i] = atoi(numofmems[i]);
}
for ( int i = 0; i < 20; i++ )
{
cout << setw(30) << left << clubname[i];
cout << setw(20) << left << presname[i];
cout << setw(15) << right << number[i];
cout << setw(10) << fixed << setprecision(2) << MONEY * number[i];
}
infile.close();
}
else
cout << "Error opening file!" << endl;
return 0;
}
Edit: this didn't copy and paste quite right, but the club names/presidents/members/money are all in neat columns and evenly spaced when they appear in the command prompt
This post has been edited by theant4: 01 June 2011 - 11:22 AM

New Topic/Question
Reply




MultiQuote





|