Thread: help in c++ program

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    22

    help in c++ program

    i have to desin a program that produce a tax invoice for customer passing thru different gate in a motorway
    i have done that but i got a lot of error can you help me solvin them
    that the code
    Code:
    #include <cstdlib>
    #include <iostream>
    
    using namespace std;
    void print mainheading(int& pagecount, int& linecount);
    void print columnheading(int& pagecount, int& linecount);
    void tolldetails(int& max-line, int& max-size, string& date, string& time,i,  ipstring, int$ gate);
    void caluculatetoll ( string& station, int& i, double& a, double& b ,double& c, double& d, double& total, double& contotal);
    void reset contotal( double& contotal)
    void Print tax invoice ( int&, char&, double&, double&, double&, double&);
    
    const int max-lines =100;
    const max-line =100;
    const int max-size = 20;
    double total = 0;
    int linecount =0;
    bool more = true;
    
    
    void print mainheading (int pagecount, int& linecount)
    {
         pagecount = pagecount +1;
         cout<<" Interstate Motorway tax invoice"<<endl;
         cout<<" customer id\tname\tadress\n";
         line count =2;
    }
    
    void print columnheading (init pagecount; int& linecount)
    {
          pagecount = pagecount +1;
         cout<< "Date\t\t time\t\t Amount\n\n";
         lne count=1;
    }
    void tolldetails(int& max-line, int& max-size, string& date, string& time,i,  ipstring, int$ gate)
    {
         date [max-size];
         time [max-size];
          i =0;
          do
               {
               cerr <<" proceeding:"<< endl;
               getline (cin, ipstring);
                if(cin.fail()) 
                break;
                
                int gate = ipstring.find ('/');
                date[i] = ipstring.substr 
                time[i] = ipstring.substr 
               i++;
               }
             while (i< max-size);
             for ( int j=0, j<i, j++)
             cout<< date [j]<<"\t" << time[j]<< endl;
    }
     void caluculate toll ( string& station, int& i, double& a, double& b ,double& c, double& d, double& total, double& contotal)
     {
          a = 0;
          b = 0;
          c = 0;
          d = 0;
          int j = 0
          do
          {
              if (station [j] == "A")
              {
                          a = a + 2.20;
                          cout <<a;
                          }
                          else if (station[j] == "B")
                          {
                          b = b +  2.80;
                          cout <<b;
                          }
                          else if ( station [j] == "C")
                          {
                               c = c+ 2.30;
                               cout<< c;
                               }
                          else if ( station [j] == "D")
                          {
                               d = d + 3.80;
                               cout<< d;
                               }
                               
                               total = a+ b + c + d;
                               cout << "THE TOTAL AMOUNT IS"<< total<< endl;
                               cout<< " PLEASE MAKE THE PAYMENT AS SOON AS YOU CAN"<< endl;
                               resetcontotal ( contotal);
                               }
                      while (j< i);
    }                 
                               
    void reset contotal( double& contotal)
    {
         contotal = 0;
         }
         int main ()
         {  
             int currentid;
             int previd;
             string custid;
             string prevcustid;
             double total;
             double contotal;
             int linecount;
             
             previd = currentid;
             prevcustid = custid;
             while (more)
             {
                    if ( currentid = previd)
                    caluculate total  ( max-size, station, i, a, b,c, d)
                    previd= currentid;
                    prevcustid= custid;
                    a}
                    if (linecount > max-lines)
                    print main heading (linecount);
                    print column heading (linecount);
                    read tolldetails ( max-line, max-size, date, time, ipstring, i,gate);
                    calculate total( max-size, station, a,b,c,d,total);
                    system ("pause");
                    return 0;
    and thanks for your help

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    please try to help me because i need to submit it tommorow morning
    and i still have to fix my defining diagram and my flow chart
    and thx

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    What's the error.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    i got an error message saying that print does not name a type

  5. #5
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    All of your function definitions have multiple words in the identifier. That's illegal. For instance
    Code:
    void print column header();
    
    // should properly be
    
    void print_column_header();
    Even with the multiple words, I see some discrepencies between your function prototypes and function calls. That has to change. The compiler can't identify syntax errors and auto fix them for you. You have to make sure you calls look exactly like your definition and prototype. That includes CASE in C++.
    Last edited by SlyMaelstrom; 05-31-2006 at 09:54 PM.
    Sent from my iPadŽ

  6. #6
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    i wrote by myself using some books in c++
    and it look so messy that's why im here to aask for help

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Yes, I editted what I said. I apologize for the accusation, I had just not noticed what you were trying to do there, I now see what your problem was. I also am sure there are other problems in there that I can't bother looking at until you fix the first major one. For instance, your brackets aren't all closed.
    Sent from my iPadŽ

  8. #8
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    i now got a message that ipstring is not declared
    what shoul i do

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    You can expect us to fix little syntax errors like that. Based on your understanding, I want you to review the code line by line again. In the function prototypes alone, there are several syntax errors that you could identify.

    Also, look up the rules on declaring identifiers. You have several illegal ones in there, including the use of hyphens. I'd also hate to come down on you like this, but you also might want to check out the forums' Homework Policy.
    Sent from my iPadŽ

  10. #10
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    if you still around i will try to fix what i can ang give it to you to look at it

  11. #11
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Well, I have a strong feeling that as soon as you fix all of the syntax errors, the program is going to work fine.
    Sent from my iPadŽ

  12. #12
    Registered User
    Join Date
    Apr 2006
    Posts
    22

    Unhappy

    i try to do all what i can but i stil receive error message can i get someone to helpme plz
    Code:
    #include <iostream>
    #include <string.h>
    using namespace std;
    
    void print_main_Heading(int&, int&);
    void print_Column_Heading(int&, int&);
    void readtolldetails (int& , int& , string& , string& , string& ,int& , int& );
    void calculateToll(int& , char& , int& , double& , double& , double& , double& );
    void resetContotals(double&);
    void printTotalInvoice (int& , char& , double& , double& , double& , double& , double& );
    
    const int MAX_LINES =100;
    const int MAX_LINE = 100;
    const int MAX_SIZE = 20;
    double TotalInvoice = 0;
    int pageCount = 0;
    int lineCount = 0;
    bool more= true;
    
    void print_main_Heading(int& pageCount, int& lineCount)
    {
         pageCount = pageCount +1;
         cout<<"Interstate motorway tax invoice"<<endl;
         cout<<"cutomer id\tname\adress" ;
         lineCount = 2;
         }
         
    void print_Column_Heading(int& pageCount, int& lineCount)
    {
         pageCount = pageCount +1;
       
         cout<<"DATE\t\tTIME\tAMOUNT\n\n";
         
         lineCount = 1;
         }
    
    void readtolldetails(int& MAX_LINE, int& MAX_SIZE, string& date, string& time, string& ipString,int& i, int&gate)
    {
        
        date [MAX_SIZE];
        time [MAX_SIZE];
        ipString;
      i =0;
        
        do {
            cerr<<"proceeding..."<<endl;
            getline(cin, ipString);   
            if(cin.fail()) break;  
            
            int position = ipString.find ('/');
            date [i] = ipString.substr; 
            time [i]= ipString.substr; 
            i++;
            }
            while (i<MAX_SIZE);
            
            for (int j=0; i<j; i++)
            cout <<date[j]<<"\t"<<time[j]<<endl;
                          
    }
      void calculatetoll (string& station, int i, float& a, float& b, float& c, float&d,float& total, double& contotal)
    {  
       a = 0;
       b = 0;
       c = 0;
       d = 0;
        
       int j = 0;
       do
       {
          
           if (station [j] == 'A')
           {               
                       a= a + 2.20;
                       cout<<a;
           }
    
         else if(station[j] == ' B')
         {               
                       b= b + 2.80;
                       cout<<b;
           }
            else if(station[j] == ' C')
         {               
                     c= c + 2.30;
                       cout<<c;
           }
            else if(station[j] == ' D')
         {               
                       d= d + 3.80;
                       cout<<d;
           }
           
            totalI = a + b+ c + d;
     cout<<"TOTAL:" << total <<endl;
    
     cout<<"please make payment as soon as possible."<<endl;
     resetContotals(contotal);
     
           
      }
      while(j < i);
    }
         
         void resetContotals(double& contotal)
         
         {
         contotal = 0;  
         }
    
    
    
    int main ()
    {
    int currentid;
    int previd;
    string custid;
    string prevcustid;
    double Total;
    double contotal;
    int pageCount;
    int lineCount;
    
    previd =currentid;
    prevcustid=custid;
             while(more)
             {
                   if (currentid!=previd)
                   calculateStation (MAX_SIZE, station, count, totalA, totalB, totalC, totalD); 
                   previd= currentid;
                   prevcustid= custid;
                   }
                   if (lineCount >MAX_LINES)
                   printmainHeading(pageCount, lineCount);
                   printcolumnHeading(pageCount, lineCount);
                   readtolldetails (MAX_LINE, MAX_SIZE, date, time, inputString, count, position); 
                   calculateTotalStation (MAX_SIZE, station, i, a, b, c, d );
                   printTotalInvoice (MAX_SIZE, station, a, b, c, d, total);
    
                   system("pause");
                   return 0;
    }

    and thank you for help
    Last edited by halloula; 05-31-2006 at 11:20 PM.

  13. #13
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Again, print_main_Heading is not the same as printmainHeading as with other functions in your code; function signatures must match verbatim.

  14. #14
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    i did correct that but i still got error message in line 51

  15. #15
    Registered User
    Join Date
    Apr 2006
    Posts
    22
    that's the last stage i reached but still have errors i feel so bad i couldnt do better than that please try to help with any hints
    Code:
    #include <iostream>
    #include <string.h>
    using namespace std;
    
    void print_main_Heading(int&, int&);
    void print_Column_Heading(int&, int&);
    void readtolldetails (int& , int& , string& , string& , string& ,int& , int& );
    void calculateToll(int& , char& , int& , float& , float& , float& , float& );
    void resetContotals(double&);
    void printTotalInvoice (const int& , char& , float& , float& , float& , float& , float& );
    
    const int MAX_LINES =100;
    const int MAX_LINE = 100;
    const int MAX_SIZE = 20;
    double TotalInvoice = 0;
    int pageCount = 0;
    int lineCount = 0;
    bool more= true;
    
    void print_main_Heading(int& pageCount, int& lineCount)
    {
         pageCount = pageCount +1;
         cout<<"Interstate motorway tax invoice"<<endl;
         cout<<"cutomer id\tname\adress" ;
         lineCount = 2;
         }
         
    void printCustomerHeading(int& pageCount, int& lineCount)
    {
         pageCount = pageCount +1;
       
         cout<<"DATE\t\tTIME\tAMOUNT\n\n";
         
         lineCount = 1;
         }
    
    void readtolldetails (int& MAX_LINE, int& MAX_SIZE, string& date, string& time, string& ipString,int& i, int&gate)
    {
        
        date [MAX_SIZE];
        time [MAX_SIZE];
        ipString;
      i =0;
        
        do {
            cerr<<"proceeding..."<<endl;
            getline(cin, ipString);   
            if(cin.fail()) break;  
            
            int position = ipString.find ('/');
            date [i] = ipString.substr(0, 10);  
            time [i] = ipString.substr(11,16-11);   
            i++;
            }
            while (i<MAX_SIZE);
            
            for (int j=0; i<j; i++)
            cout <<date[j]<<"\t"<<time[j]<<endl;
                          
    }
      void calculatetoll (string& station, int i, float& a, float& b, float& c, float&d,float& total, double& contotal)
    {  
       a = 0;
       b = 0;
       c = 0;
       d = 0;
        
       int j = 0;
       do
       {
          
           if (station [j] == "A")
           {               
                       a= a + 2.20;
                       cout<<a;
           }
    
         else if(station[j] == " B")
         {               
                       b= b + 2.80;
                       cout<<b;
           }
            else if(station[j] == "C")
         {               
                     c= c + 2.30;
                       cout<<c;
           }
            else if(station[j] == "D")
         {               
                       d= d + 3.80;
                       cout<<d;
           }
           
            total = a + b+ c + d;
     cout<<"TOTAL:" << total <<endl;
    
     cout<<"please make payment as soon as possible."<<endl;
     resetContotals(contotal);
     
           
      }
      while(j < i);
    }
         
         void resetContotals(double& contotal)
         
         {
         contotal = 0;  
         }
    
    
    
    int main ()
    {
    int currentid;
    int previd;
    string custid;
    string prevcustid;
    
    double contotal;
    int pageCount;
    int lineCount;
    char station;
    int i;
    float a, b, c, d, total;
    string ipstring;
    
    previd =currentid;
    prevcustid=custid;
             while(more)
             {
                   if (currentid!=previd)
                   calculateToll (MAX_SIZE, station, i , a , b, c, d); 
                   previd= currentid;
                   prevcustid= custid;
                   }
                   if (lineCount >MAX_LINES)
                   print_main_Heading(pageCount, lineCount);
                   print_Column_Heading(pageCount, lineCount);
                   readtolldetails (MAX_LINE, MAX_SIZE,ipString, i); 
                   calculateToll(MAX_SIZE, station, i, a, b, c, d );
                   printTotalInvoice (MAX_SIZE, station, a, b, c, d, total);
    
                   system("pause");
                   return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM