| | |
Using control breaks to subtotal inputfile data
![]() |
•
•
Join Date: Jul 2009
Posts: 17
Reputation:
Solved Threads: 0
For this project I am suppose to create a data file which includes this info:
Miller Ford Mustang 28000
Miller Ford Escape 23000
Miller Ford Van 32000
Sam_Car Ford Focus 17000
Sam_Car Ford Ranger 18250
Sam_Car Chev Impala 31500
Tina_Sells Chev Camero 33000
Tina_Sells Chev SUV 38000
Then I am suppose to create a program that reads in all the data but uses a control break, one that subtotals each salespersons sales. then it it suppose to display the read data including the subtotal, and earned commission which is 4% of the total sales (subtotal).
This is what I have so far, it read all the data and displays it. I just need help on how to start on the subtotaling for each seller? Can anyone show me an example or lead me in the direction to a solution for my program? Thanks.
Miller Ford Mustang 28000
Miller Ford Escape 23000
Miller Ford Van 32000
Sam_Car Ford Focus 17000
Sam_Car Ford Ranger 18250
Sam_Car Chev Impala 31500
Tina_Sells Chev Camero 33000
Tina_Sells Chev SUV 38000
Then I am suppose to create a program that reads in all the data but uses a control break, one that subtotals each salespersons sales. then it it suppose to display the read data including the subtotal, and earned commission which is 4% of the total sales (subtotal).
This is what I have so far, it read all the data and displays it. I just need help on how to start on the subtotaling for each seller? Can anyone show me an example or lead me in the direction to a solution for my program? Thanks.
C++ Syntax (Toggle Plain Text)
///Preprocessive directives #include "stdafx.h" #include <iostream> #include <fstream> #include <iomanip> using namespace std; //Prototypes void initialization(); void process (); void eoj (); void openIt(); void readIt(); void writeIt(); void calculateIt(); void accumulateIt(); //Input Records ifstream inputFile; char sSalesPerson[15]; char sMake[10]; char sModel [10]; int iSellingPrice; //Program Variables int iEarnedCommission; int main() { cout << "\n\t\tWeekly Car Sales Report\n\n"; cout << "Salesperson Make Model Selling Price\n"; cout << "-------------------------------------------------\n"; initialization(); if (!inputFile.fail()) { process(); } eoj(); return 0; } void initialization() { openIt(); return; } void process () { readIt(); while (!inputFile.eof()) { calculateIt(); accumulateIt(); writeIt(); readIt(); } return; } void eoj () { inputFile.close(); return; } void openIt() { inputFile.open("c:\\auto.dat"); if (inputFile.fail()) cout << "AUTO file open failed" << endl; return; } void readIt() { inputFile >> sSalesPerson >> sMake >> sModel >> iSellingPrice; return; } void calculateIt() { return; } void accumulateIt() { return; } void writeIt() { cout << left << setw(15) << sSalesPerson << setw(12)<< sMake << setw(12) << sModel << setw(12) << iSellingPrice << endl; return; }
![]() |
Similar Threads
- Using Data Control.. Sumbody plz guide me.. (Visual Basic 4 / 5 / 6)
- Send data on a serial port (C++)
- im lost and need help (Computer Science)
- How to access rptImage Control of data report runtime? (Visual Basic 4 / 5 / 6)
- posting data from a form to msg broker fail (RSS, Web Services and SOAP)
- About Mscomm Control (Visual Basic 4 / 5 / 6)
- Archive MSaccess data into a different Access DB (Visual Basic 4 / 5 / 6)
- ASP.NET 2.0, Parent/Child Data Control? (ASP.NET)
- Design for A4 printing HTML report - Pg Break? (JavaScript / DHTML / AJAX)
- Classes and using Static member functions to subtotal/total (C++)
Other Threads in the C++ Forum
- Previous Thread: Question
- Next Thread: Problem with subexpression in regex
Views: 559 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
algorithm api array arrays assignment basic beginner binary c++ c/c++ calculator char class classes code command compile compiler console constructor conversion convert count data delete desktop dll dynamic encryption error file files fstream function functions game givemetehcodez graph gui homework http i/o iamthwee image input int lazy library linker list loop looping math matrix member memory newbie number numbers object objects opengl output parameter pointer pointers problem program programming project random read recursion recursive reference search sort sorting spoonfeeding string strings struct student studio template templates text time tree variable vc++ vector video visual visualstudio void win32 window windows winsock





