| | |
Using control breaks to subtotal inputfile data
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2009
Posts: 14
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
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count data delete deploy desktop developer directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





