Thread: need help on how to start

  1. #1
    Registered User
    Join Date
    May 2006

    Unhappy need help on how to start

    Interstate Motorway Pty Limited requires you to design a program that will 
    produce customer statements for passing through E-way checkpoints of four 
    toll stations (denoted by A, B, C and D respectively) distributed on the 
    nationwide motorway. The charge of each pass is specified as follows 
    Station	A	B	C	D
    Charge	$2.20	$2.80	$2.30	$3.80
    These statements will be calculated from the checkpoint log file of the format 
    3435344 A   2005/02/22/08:22:41
    4749038 A   2005/02/25/14:16:35
    5186936 C   2005/02/28/08:34:53
    3873242 D   2005/03/02/02:40:59
    4749038 A   2005/03/05/14:16:35
    4092191 A   2005/03/08/23:49:08
    3435344 C   2005/03/11/08:22:41
    4092191 C   2005/03/14/23:42:08
    4749038 D   2005/03/17/14:16:35
    3435344 A   2005/03/20/08:22:41
    where the first column contains customer ids, the second column contains the 
    toll stations and the last column contains the timestamps. Hence the first record
     in the above, for instance, indicates that the vehicle with tag number (i.e. 
    customer id) 3435344 passed through toll station A at time 08:22:41 on 22nd February 2005. 
    In order that each statement carries also the customer's name and address, the 
    address file will be provided in the form of 
    3435344 @   L Brooks,12 Shaftsbury Road,Burwood NSW 2134
    3873242 @   N McGoldrick,8 Colless Place,South Melbourne VIC 3205
    4092191 @   T Peachey,32 Evan Street,Penrith NSW 2750
    4749038 @   D Merritt,70 Albert Street,Werrington NSW 2747
    4967987 @   R Bailey,102-47 Pardalote Avenue,Glenmore Park NSW 2745
    5186936 @   S Galloway,8-121 Coreen Road,Scoresby VIC 3179
    For the convenience of processing the log file for the statements, the address 
    file and the log file will be first merged and then sorted line by line 
    alphabetically to generate the toll data file, which will thus look like 
    3435344 @   L Brooks,12 Shaftsbury Road,Burwood NSW 2134
    3435344 A   2005/02/22/08:22:41
    3435344 A   2005/03/20/08:22:41
    3435344 B   2005/03/23/18:22:41
    3435344 B   2005/04/10/28:22:41
    3435344 C   2005/03/11/08:22:41
    3435344 C   2005/05/10/14:22:41
    3435344 C   2005/05/19/06:22:43
    3435344 D   2005/05/01/01:26:41
    3873242 @   N McGoldrick,8 Colless Place,South Melbourne VIC 3205
    3873242 B   2005/03/29/02:40:59
    3873242 B   2005/05/16/02:40:59
    3873242 C   2005/04/07/22:40:59
    3873242 D   2005/03/02/02:40:59
    For instance, if an address file address.txt is mergered with a log file logfile.txt
     into a combined file combined.txt, then sorting the combined file will generate 
    the needed toll data file tolldata.txt. Hence in this assignment, we will always 
    assume that the input data are in the form of toll data file and simply forget 
    about the existence of the log file and the address file. 
    In this assignment, you are required to design an algorithm in pseudocode for 
    the solution of the problem and get it implemented in C++. Your implemented 
    C++ program toll.cpp will read data in the format of the toll data file, i.e. 
    o	customer id as a word 
    o	toll station or '@' as a character 
    o	customer address or timestamp as the rest of the line 
    calculate the total toll charged for each customer, and produce an invoice 
    statement for each customer who has a non-zero balance. A statement for each
     customer should include the following information 
    4.	Heading 
    5.	Customer's id, name and address 
    6.	Column heading: Date, Time, Station, Amount 
    7.	All records charged to the customer 
    8.	Total amount the customer owned in the statement 
    We note that if your program toll.cpp is compiled into toll.exe and the toll data 
    file is tolldata.txt, then using piping 
    toll.exe < tolldata.txt > statements.txt
    should generate precisely the list of toll statements satisfying the above requirements. 
    This means if you are using prompts for interative data input, you 
    need to make sure that the prompts are sent to standard error device using cerr 
    (instead of cout). This way, the prompts will not be piped into the output file 
    For the top marks, there should be considerations on the unexpected 
    circumstances such as corrupted individual records etc, and the program 
    should be able to report and handle such anomalies accordingly. Such 
    endeavours should be properly documented as well. 
    The following sample program shows a program can be run interactively (input 
    provided by a user), or run by piping (input is provided as the content of a file). 
    // code here updated on 26/04
    using namespace std;
    int main() {
      long id;
      char station;
      string rest;
      while(true) {
        cerr << "ID->";        //send prompt to standard error device (console) 
        cin >> id;
        if( break;  // abort program upon any input failure
        cerr << "Station->";
        cin >> station;
        if( break;
        cerr << "Rest->";   
        cin >> ws;             //skip white spaces
        getline(cin, rest);    //read a whole line into string variable "rest"
        if( break;
        cout << id << ' ' << rest << endl;
      // system("pause");
      return 0;
    Last edited by Salem; 05-31-2006 at 11:38 PM. Reason: Line wrapping for width

  2. #2
    Registered User
    Join Date
    May 2006
    How much will you pay me ?

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    United States
    I have the solution:
    #include <cstdio> 
    int main(){for(;;)std::puts("do your own homework");}

  4. #4
    Registered User
    Join Date
    May 2006
    Ahah, on another post he said it was what he'd done so far.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  3. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 11:48 PM
  4. GNOME Desktop won't start (Mandriva)
    By psychopath in forum Tech Board
    Replies: 10
    Last Post: 07-19-2006, 01:21 PM
  5. Start bar color in WinXP
    By confuted in forum Tech Board
    Replies: 4
    Last Post: 05-03-2003, 06:18 AM