Hello. So this code isn't working. I have to create a program that:
- define class cust(I already did this part)
- create an array of cust (size 10)to hole the data of the class.
- read the date from a file(everything from the class)
- call a function print cust(this function will print all the data in table format)....first, last, state, sales history(0,1,2), units
- Read the data from a file (you may break up the strings and numeric values any way
you choose (separate lines may be easier)
- Make a function call to a function called printcust. This function will print all the
data for all of the customers (in tabular format similar to the layout of the input
data below).
- Make a function call to a function called sortname which will sort the cust array
alphabetically by last name.
- Make a function call to the function printcust.
- Make a function call to a function called sortsales. This function will sort the above
array in descending order of the total sales.
- Call the function printcust
I don't know what I'm doing wrong.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
class sales_info{
public:
};
class customer{
public:
string first;
string last;
string state;
double sHistory[3]; // Sales history for three years.
double totalSales; // Total sales (adding all three years together)
int purchaseUnits;
};
void printcust(customer[], int);
void sortname(customer[], int);
void sortsales(customer[], int);
int main () {
customer cust[10];
int i;
for(int i = 0; i < 10; i++)
customer cust[i];
fstream infile;
infile.open("data.txt");
getline(infile, cust[i].first);
getline(infile, cust[i].last);
getline(infile, cust[i].state);
infile >> customer.purchaseUnits[]
}
| |