help in c++ program


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: help in c++ program

  1. #1
    Join Date
    May 2006
    Posts
    2

    help in c++ program

    please help find the error and correct them in this program
    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 thx for your help

  2. #2
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    Well, you could start by removing the spaces in your function and variable names. You're not trying to get us to do your school assignment for you, by any chance?

    Rune
    If you hit a brick wall, you didn't jump high enough!

  3. #3
    Join Date
    May 2006
    Posts
    2
    Quote Originally Posted by Rune Bivrin
    Well, you could start by removing the spaces in your function and variable names. You're not trying to get us to do your school assignment for you, by any chance?

    Rune
    the assigment asked me to build the program and that's what i've done but i still got errors i reached this final stage now but i still got problems
    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;
    }

    dont accuse peope

  4. #4
    Join Date
    Nov 2004
    Location
    Huddinge, Sweden
    Posts
    283
    You don't suppose telling what problems you're experiencing might help?

    Without compiling the code I can tell that you're both declaring MAX_LINE and MAX_SIZE as constants and as parameters to readtolldetails(). The parameter declaration takes precedence, and C++ doesn't allow declaring array sizes using variables, unless you use new/delete (or malloc/free) to reserve the memory.

    I'm not accusing anyone, but an assignment is just that. It's something you must do yourself. It's OK to ask questions on specific details, but to just hand over the code and say "Help!" won't actually help you learn anything, which is what school is about, after all.

    Rune
    If you hit a brick wall, you didn't jump high enough!

Similar Threads

  1. soft drink Vending machine program
    By divagoddess in forum C++
    Replies: 5
    Last Post: 08-14-2009, 04:12 PM
  2. Help with a program
    By stormswimmer in forum Java
    Replies: 2
    Last Post: 01-02-2006, 04:17 PM
  3. problem in program in c++
    By mheasen in forum Architecture and Design
    Replies: 0
    Last Post: 03-20-2002, 10:24 AM
  4. Please help with running executable vb program.
    By Gordon Reichhardt in forum VB Classic
    Replies: 2
    Last Post: 01-08-2002, 11:06 AM
  5. How can I build copy protection into my program
    By W.Pierce in forum VB Classic
    Replies: 1
    Last Post: 12-11-2001, 09:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center