473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Cannot have a type qualifier...?

SSJTactics
This is a program on Telephone Billing. There's only one error and it says- "Identifier 'append' cannot have a type qualifier.

Expand|Select|Wrap|Line Numbers
  1. //**********************************************************************************
  2. //    PROJECT TELEPHONE-BILLING
  3. //**********************************************************************************
  4. //    TELEPHONE BILLING 
  5.  
  6. //Header files
  7.  
  8. #include<stdio.h>
  9. #include<conio.h>
  10. #include<string.h>
  11. #include<process.h>
  12. #include<ctype.h>
  13. #include<dos.h>
  14. #include<dir.h>
  15. #include<fstream.h>
  16.  
  17. //Class having the record of customer
  18.  
  19. class customer
  20. {    char ph[10];
  21.     char name[30];
  22.     char add[40];
  23.     char type;
  24.  
  25.     public:
  26.     void append();
  27.     void display();
  28.     void deleter();
  29.     void modify();
  30.     void list();
  31.     void help();
  32. } cust;
  33.  
  34. //Function to display the message at the bottom of the screen
  35.  
  36. void message (char mess[80])
  37. {
  38.     int l, d;
  39.     l = strlen(mess);
  40.     d=l/2;
  41.     gotoxy(2,24);
  42.     textcolor(WHITE+BLINK);
  43.     textbackground(BLACK);
  44.     cprintf("                                                 ");
  45.     gotoxy(40-d, 24);
  46.     clreol();
  47.     cprintf("%s", mess);
  48.     textcolor(BLACK);
  49.     textbackground(WHITE);
  50. }
  51.  
  52. //Main function having the main menu
  53.  
  54. void main()
  55. {
  56.     textcolor(BLACK);
  57.     textbackground(WHITE);
  58.     char ch, ch1;
  59.     while(1)
  60.     {
  61.         clrscr();
  62.         textcolor(BLACK);
  63.         textbackground(WHITE);
  64.         gotoxy(25,5);
  65.         cprintf("MAHANAGAR TELEPHONE NIGAM LTD.");
  66.         textcolor(BLACK);
  67.         textbackground(WHITE);
  68.         gotoxy(25,8);
  69.         cout<<"    D    -    Display a Bill";
  70.         gotoxy(25,10);
  71.         cout<<"L        -    List of Customers";
  72.         gotoxy(25,12);
  73.         cout<<"H    -    Help";
  74.         gotoxy(25,14);
  75.         cout<<"M    -    Modify a Record";
  76.         gotoxy(25,16);
  77.         cout<<"Q    -    Quit";
  78.         message("Select your Choice");
  79.         gotoxy(40,18);
  80.  
  81.         ch=getch();
  82.         ch=toupper(ch);
  83.         switch(ch)
  84.         {
  85.         case('Q')    : textcolor(WHITE);
  86.                textbackground(BLACK);
  87.                clrscr();
  88.                exit(1);
  89.         case('D')    : cust.display();
  90.                break;
  91.         case('L')     : cust.list();
  92.                break;
  93.         case('H')    : cust.help();
  94.                break;
  95.         case('M'):
  96.             ch1 = 'A';
  97.             while(ch1 != 'Q' )
  98.             {
  99.                 clrscr();
  100.                 textcolor(WHITE);
  101.                 textbackground(BLACK);
  102.                 gotoxy(25,5);
  103.                 cprintf("MAHANAGAR TELEPHONE NIGAM LTD.");
  104.                 textcolor(BLACK);
  105.                 textbackground(WHITE);
  106.                 gotoxy(25,9);
  107.                 cout<<"A        -    Append a record";
  108.                 gotoxy(25,11);
  109.                 cout<<"D    -    Delete a record";
  110.                 gotoxy(25,13);
  111.                 cout<<"M    -    Change a record";
  112.                 gotoxy(25,15);
  113.                 cout<<"Q        -    Quit";
  114.                 message("Select your option");
  115.                 ch1 = getch();
  116.                 ch1 = toupper(ch1);
  117.                 switch(ch1)
  118.                 {
  119.                     case('A') : cust.append();
  120.                            break;
  121.                     case('D') : cust.deleter();
  122.                            break;
  123.                     case('M') : cust.modify();
  124.                            break;
  125.                 }
  126.         }    
  127.     }
  128.    }
  129. }
  130.  
  131. //Function to add the customer record in the file
  132.  
  133. void customer :: append()
  134. {
  135.     char choice;
  136.     fstream fp;
  137.     fp.open("tphone.dat", ios::app);
  138.     if (!fp)
  139.     {
  140.         cout<<"Unable to open FILE.";
  141.         getch();
  142.         return;
  143.     }
  144.     while(1)
  145.     {
  146.         clrscr();
  147.         gotoxy (3,3);
  148.         cout<<"Customer Record #";
  149.         message("Enter the customer record");
  150.         while(1)
  151.         {
  152.             message("Enter the name");
  153.             gotoxy(3,5);
  154.             cout<<"Name    :    ";
  155.             gotoxy(25,5);
  156.             gets(name);
  157.             if(strlen (name) == 0)
  158.             {
  159.                 gotoxy(2,23);
  160.                 clreol();
  161.                 textcolor(WHITE+BLINK);
  162.                 textbackground(BLACK);
  163.             }
  164.             else
  165.             break;
  166.         }
  167.  
  168.         while(1)
  169.         {
  170.             gotoxy(3,7);
  171.             cout<<"Assigned Ph. No.    :    ";
  172.             gotoxy(25,7);
  173.             cin>>ph;
  174.             if (ph != 0 )
  175.                 break;
  176.             else
  177.             {
  178.                 gotoxy(25,7);
  179.                 clreol();
  180.             }
  181.         }
  182.  
  183.         message ("Enter O for Office and R for Residential phone");
  184.         gotoxy (3,8);
  185.         cout<<"Category (O/R)    :    ";
  186.         cin>>type;
  187.         gotoxy(4,10);
  188.         cout<<"1 : Save & Exit    2 : Save & Cont.    0 : Exit without save";
  189.         gotoxy(4,11);
  190.         cout<<"?  ";
  191.         cin>>choice;
  192.         switch(choice)
  193.         {
  194.             case ('1') : fp.write ( (char *) this, sizeof (cust) );
  195.                    fp.close();
  196.                    return;
  197.             case ('2') : fp.write( (char *) this, sizeof (cust) );
  198.                    break;
  199.             case ('0') : fp.close();
  200.                    return;
  201.             default     : fp.close();
  202.                    return;
  203.         }
  204.     }
  205. }    
  206.  
  207. //Function to display the customer record and calculate the bill
  208.  
  209. void customer :: display()
  210. {
  211.     char p[10];
  212.     char choice;
  213.     int found=0;
  214.     int no;
  215.     float bill=0.0, tax=0.0, fine=0.0, bbill=0.0, abill=0.0;
  216.     fstream fp;
  217.     fp.open("tphone.dat", ios::in);
  218.     if (!fp)
  219.     {
  220.         cout<<"Unable to open a file";
  221.         getch();
  222.         fp.close();
  223.         return;
  224.     }
  225.  
  226.     while (choice != '0' )
  227.     {
  228.         clrscr ();
  229.         gotoxy(3,20);
  230.         cout<<"Please enter the Phone No. ";
  231.         cin>>p;
  232.         if (!strcmp(p,"0"))
  233.             return;
  234.         found = 0;
  235.         fp.seekg(0);
  236.         while (fp.read ( (char *) this, sizeof (cust) ) )
  237.         {
  238.             if (founf==1)
  239.                 break;
  240.             if(!strcmp (ph,p) )
  241.             {
  242.                 clrscr();
  243.                 gotoxy(28,2);
  244.                 textcolor(BLACK+BLINK) ;
  245.                 textbackground(WHITE);
  246.                 cprintf("MAHANAGAR TELEPHONE BILL");
  247.                 textcolor(WHITE);
  248.                 textbackground(BLACK);
  249.                 gotoxy(3,4);
  250.                 cout<<"Name        :   ";
  251.                 cout<<name;
  252.                 gotoxy(35,5);
  253.                 cout<<"Address        :   ";
  254.                 cout<<add;
  255.                 gotoxy(35,4);
  256.                 cout<<"Assigned Ph. No.    :   ";
  257.                 cout<<ph;
  258.                 gotoxy(3,5);
  259.                 cout<<"Category ( O/R )    :   ";
  260.                 cout<<type;
  261.                 gotoxy(23,8);
  262.                 cout<<"_____________";
  263.                 gotoxy(10,8);
  264.                 cout<<"No. of calls ";
  265.                 cin>>no;
  266.                 if ( no <= 150 )
  267.                     bill = 0;
  268.                 else
  269.                 {
  270.                 no = no - 150;
  271.                 if ( toupper (type) == 'O')
  272.                     bill = np * 1.00 ;
  273.                 else
  274.                     bill = no * .80;
  275.             }
  276.  
  277.             gotoxy (10,9);
  278.             cout<<"Bill";
  279.             gotoxy (70,9);
  280.             cout<<bill;
  281.             tax = (5*bill) / 100;
  282.             gotoxy (10,10) ;
  283.             cout<<"5 % Tax ";
  284.             gotoxy (70,10);
  285.             cout<<tax;
  286.             gotoxy (10,11);
  287.             cout<<"Duties";
  288.             gotoxy (70,11);
  289.             cout<<"100";
  290.             int dd, mm, yy;
  291.             struct date d;    //Getting system date
  292.             getdate (&d);
  293.             dd = d.da_day;
  294.             mm = d.da_mon;
  295.             yy = d.da_year;
  296.             gotoxy (10,15);
  297.             cout<<"TOTAL BILL before ";
  298.             cout<<dd<<"/"<<mm<<"/"<<yy;
  299.             bbill = bill+tax+100;
  300.             gotoxy (70,15);
  301.             cout<<bbill;
  302.             gotoxy (10,17);
  303.             cout<<"Late Fine";
  304.             fine = (bbill*5) / 100;
  305.             gotoxy (70,17);
  306.             cout<<fine;
  307.             gotoxy (10,21);
  308.             cout<<"TOTAL BILL after ";
  309.             cout<<dd<<"/"<<mm<<"/"<<yy;
  310.             abill = bbill + fine;
  311.             gotoxy (70,21);
  312.             cout<<abill;
  313.             found = 1;
  314.             message ("Press a Key");
  315.             getch();
  316.         }
  317.     }
  318.  
  319.     message ("Enter 1 or 2 to cont.");
  320.     gotoxy (4,22);
  321.     cout<<"1 : Cont.    0 : Exit ";
  322.     cout<<"?  ";
  323.     cin>>choice;
  324.  
  325.     switch(choice)
  326.     {
  327.         case ('1') :
  328.                break;
  329.         case ('0') : return;
  330.         default     : return;
  331.     }
  332.        }
  333.        fp.close();
  334. }
  335.  
  336. //Function to display the list of the customers
  337.  
  338. void customer :: list()
  339. {
  340.     clrscr();
  341.     fstream fp;
  342.     int r;
  343.     fp.open ("tphone.dat"; ios::in);
  344.     if ( !fp )
  345.     {
  346.         cout<<"Unable to open";
  347.         getch();
  348.         fp.close();
  349.         return;
  350.     } 
  351.  
  352.     gotoxy (35,2);
  353.     cout<<"List of customers";
  354.     gotoxy (35,3);
  355.     cout<<"**************";
  356.     gotoxy (5,4);
  357.     cout<<"Name";
  358.     gotoxy (40,4);
  359.     cout<<"Phone No.";
  360.     gotoxy (65,4);
  361.     cout<<"Category";
  362.     gotoxy (1,5);
  363.  
  364. cout<<"***********************************************************************************************";
  365.     r=6;
  366.     while ( fp.read (char *) this, sizeof (cust) ) )
  367.     {
  368.         if (r >= 21)
  369.         {
  370.             message ("Press a key");
  371.             getch();
  372.             clrscr();
  373.             gotoxy (35,2);
  374.             cout<<"List of customers";
  375.             gotoxy (35,3);
  376.             cout<<"**************";
  377.             gotoxy (5,4);
  378.             cout<<"Name";
  379.             gotoxy (40,4);
  380.             cout<<"Phone No.";
  381.             gotoxy (65,4);
  382.             cout<<"Category";
  383.             gotoxy (1,5);
  384.  
  385. cout<<"***********************************************************************************************";
  386.         r=6;
  387.         }
  388.  
  389.         gotoxy (5,r);
  390.         cout<<name;
  391.         gotoxy (40,r);
  392.         cout<<ph;
  393.         gotoxy (65,r);
  394.         if (toupper (cust.type) == 'O' )
  395.             cout<<"Office";
  396.         else
  397.             cout<<"Residential";
  398.         r++;
  399.     }
  400.     message ("Press a key");
  401.     getch();
  402.     fp.close();
  403. }
  404.  
  405. //Function to delete the record of customer from the file
  406.  
  407. void customer :: deleter()
  408. {
  409.     char ch;
  410.     char p[10];
  411.     fstream temp, fp;
  412.     fp.open ("tphone.dat", ios::in);
  413.     if ( !fp )
  414.     {
  415.         cout<<"Unable to open Telephone file";
  416.         getch();
  417.         fp.close();
  418.         return;
  419.     }
  420.     temp.open ("temp.dat", ios::out);
  421.     if (!temp)
  422.     {
  423.         cout<<"Unable to open Temporary file";
  424.         getch();
  425.         temo.close();
  426.         return;
  427.     }
  428.     clrscr();
  429.     gotoxy (5,3);
  430.     cout<<"Enter the Phone No. to be deleted : ";
  431.     cin>>p;
  432.     if( !strcmp (p,"0") )
  433.         return;
  434.     int found = 0;
  435.     while (fp.read ( (char *) this, sizeof(cust) ) )
  436.     {
  437.         if ( !strcmp(p,ph) )
  438.         {
  439.             found = 1;
  440.             gotoxy (5,5);
  441.             cout<<"Name        "<<name;
  442.             gotoxy (5,6);
  443.             cout<<"Address        "<<add;
  444.             gotoxy (5,7);
  445.             cout<<"Category        "<<type;
  446.             gotoxy (6,10);
  447.             cout<<"Delete this record (Y/N) ";
  448.             cin>>ch;
  449.             if ( toupper(ch) == 'N' )
  450.                 temp.write ((char*) this, sizeof (cust) );
  451.         }
  452.         else
  453.             temp.write ((char*) this, sizeof (cust));
  454.     }
  455.     fp.close();
  456.     temp.close();
  457.     if (toupper(ch) == 'N')
  458.         return;
  459.     if (!found)
  460.     {
  461.         cout<<"\n\nTelephone no. not found";
  462.         getch();
  463.         return;
  464.     }
  465.     fp.open ("tphone.dat", ios::out);
  466.     temp.open("temp.dat", ios::in);
  467.     while (temp.read ((char*) this, sizeof(cust) ) )
  468.         fp.write ((char*) this, sizeof (cust) );
  469.     fp.close();
  470.     temp.close();
  471. }
  472.  
  473. //Function to modify the record of customer from the file
  474.  
  475. void customer :: modify()
  476. {
  477.     char ch;
  478.     char p[10];
  479.     fstream temp, fp;
  480.     fp.open ("tphone.dat", ios::in);
  481.     if (!fp)
  482.     {
  483.         cout<<"Unable to open Telephone file";
  484.         getch();
  485.         fp.close();
  486.         return;
  487.     }
  488.     temp.open ("temp.dat", ios::out);
  489.     if (!temp)
  490.     {
  491.         cout<<"Unable to open Temporary file";
  492.         getch();
  493.         temp.close();
  494.         return;
  495.     }
  496.     clrscr();
  497.     gotoxy (5,3);
  498.     cout<<"Enter the Phone No. to be modify : ";
  499.     cin>>p;
  500.     if( !strcmp(p,"0") )
  501.         return;
  502.     int found=0;
  503.     while (fp.read ((char*) this, sizeof (cust) ) )
  504.     {
  505.         if (!strcmp (p,ph) )
  506.         {
  507.             found = 1;
  508.             gotoxy (5,5);
  509.             cout<<"Name    "<<name;
  510.             gotoxy (5,6);
  511.             cout<<"Address    "<<add;
  512.             gotoxy (5,7);
  513.             cout<<"Category     "<<type;
  514.             gotoxy (6,10);
  515.             cout<<"Modify this record (Y/N) ";
  516.             cin>>ch;
  517.             if ( toupper(ch) == 'Y' )
  518.             {
  519.                 gotoxy (3,13);
  520.                 cout<<"Customer Record #";
  521.                 message ("Enter the customer record");
  522.                 while(1)
  523.                 {
  524.                     gotoxy (3,15);
  525.                     cout<<"Name    :    ";
  526.                     gets(name);
  527.                     if (strlen (name) != 0)
  528.                         break;
  529.                 }
  530.                 gotoxy (3,16);
  531.                 cout<<"Address        :    ";
  532.                 gets (add);
  533.                 while (1)
  534.                 {
  535.                     gotoxy (3,17);
  536.                     cout<<"Assigned Ph. No.    :    ";
  537.                     cin>>ph;
  538.                     if (ph != 0)
  539.                         break;
  540.                 }
  541.                 message("Enter O for Office and R for Residentil phone");
  542.                 gotoxy (3,18);
  543.                 cout<<"category (O/R)    :    ";
  544.                 cin>>type;
  545.             }
  546.         }
  547.         temp.write( (char*) this, sizeof (cust) );
  548.     }
  549.     fp.close();
  550.     temp.close();
  551.     if (toupper(ch) == 'N')
  552.         return;
  553.     if (!found)
  554.     {
  555.         cout<<"\n\nTelephone no. not found";
  556.         getch();
  557.         return;
  558.     }
  559.     fp.open ("tphone.dat", ios::out);
  560.     temp.open ("temp.dat", ios::in);
  561.     while ( temp.read ((char*) this, sizeof (cust) ) )
  562.         fp.write ((char *) this, sizeof (cust) );
  563.     fp.close();
  564.     temp.close();
  565. }
  566.  
  567. //Function to display the discription for the project working
  568.  
  569. void customer :: help()
  570. {
  571.     clrscr();
  572.     gotoxy (35,2);
  573.     textcolor (WHITE + BLINK);
  574.     textbackground (BLACK);
  575.     cprintf ("HELP");
  576.     textcolor (BLACK);
  577.     textbackground (WHITE);
  578.     gotoxy (8,5);
  579.     cout<<"Thsi software is used to create a telephone bill for the customers.";
  580.     gotoxy (8,7);
  581.     cout<<"There are two categories of the customers. First categories is of";
  582.     gotoxy (8,9);
  583.     cout<<"Resedential phones and second categories is of Office phones. Both";
  584.     gotoxy (8,11);
  585.     cout<<"the categories have different charges of the telephone bill. Charges";
  586.     gotoxy (8,13);
  587.     cout<<"of resedential phones are 80 paose per call and charges of office";
  588.     gotoxy (8,15);
  589.     cout<<"office phones are Rs. 1 per call. 150 call are free for each category";
  590.     gotoxy (8,17);
  591.     cout<<"Total bill is equal to 5% tax plus 100 rupees charges for other";
  592.     gotoxy (8,19);
  593.     cout<<"charges. If bill is not paid before the paticular date then penalty";    
  594.     gotoxy (8,21);
  595.     cout<<"should also be given.";
  596.  
  597.     getch();
  598.     };
  599. }
Jan 24 '16 #1
5 3031
weaknessforcats
9,208 Expert Mod 8TB
Where is the customer class defined? If the compiler hasn't seen the definition, then it cannot allow "customer".
Jan 24 '16 #2
@weaknessforcats I have written the entire code above. Could you please see it again? The class customer is defined first thing.
Jan 25 '16 #3
weaknessforcats
9,208 Expert Mod 8TB
I don't get your error at all. Instead I got dozens of other errors: there were typos, missing and misplaced braces, missing parentheses on function calls, using a struct date without defining it, using obsolete POSIX functions no longer supported, non-standard functions like gotoxy and cprint, etc.

It took a hour to get the errors corrected so the code would compile and the compiler said not a word about customer::append.

I suspect fixing the braces and fixing other errors fixed this error.

I appears you are using a pre-ANS C++ compiler making it at least 18 years old. I recommend getting a newer compiler. There have been a lot of changes in 18 years,
Jan 25 '16 #4
madankarmukta
308 256MB
I am not an expertise , but would like to work this issue.

May I please know at what line it is showing an error.
Jan 26 '16 #5
weaknessforcats
9,208 Expert Mod 8TB
Debugging a program is a necessary part of learning how to code.

What you should do is compile the code.

Look at the first error and fix it. Do not fix other errors. Often one error causes others to spear so it's better just to fix the first error.

The first error is when the compiler knew it was in trouble so the actual error is anyplace from there backwards toward the top of the program.

When you fix this error, recompile and look at the first error again. Fix it. Recompile. etc...

Eventually you will fix them all.

The first error you should fix is are the braces for main(). You are missing the closing brace.
Jan 26 '16 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bjgriswold | last post by:
Has anyone every seen this issue where the Forms 4.5 GUI comes up but you are unable to type anything into the username or password fields? We are using NT 4 SP 6 (TSE) with Citrix 1.8. The GUI...
27
by: alexdoulou | last post by:
Hello, I am trying to type greek fonts into common html forms on the Internet explorer but erroneous text is being typed instead of clear greek. Greek language pack is installed correctly....
8
by: minseokoh | last post by:
Hi, Could someone explain why "const" is located after the function name and what it means? inline unsigned char *access(int off) const { if (off < 0) abort(); return (&bits_); }
4
by: Ben Petering | last post by:
Hi group, this is a 'best practice' type question (I want discussion of the issue - whys and why nots - similar to "casting the return value of malloc()", to cite an analogous case). Let's...
3
by: abhijit mudugan | last post by:
i'm getting an error 'identifier display cannot have type qualifier' near the bold portion. what's wrong??? #include<iostream.h> #include<conio.h> #include<stdio.h> #include<stdlib.h> class...
1
by: KasimDelovan | last post by:
I have got this error: I get the error: Identifier 'deposit' cannot have a type qualifier I have defined this class class BankAccount { private: double balance; ...
1
by: prathamnitika | last post by:
int food :: last_code(void) { fstream file; file.open("FOOD.DAT", ios::in); file.seekg(0, ios::beg); int t=0; while(file.read((char *) this, sizeof(food))) t=itemcode; ...
1
by: Akshay143 | last post by:
#include <stdio.h> #include <conio.h> #include <string.h> #include <process.h> #include <ctype.h> #include <fstream.h> class customer {
1
by: mina444 | last post by:
1)IDENTIFIER 'GETCOUNT' CANNOT HAVE A TYPE QUALIFIER 2) AT THE END OF PROGRAM, IT DISPLAYS "COMPOUND STATEMENT MISSING }" AND "DECLARATION MISSING ;" how can I solve it? #include<stdio.h>...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.