y am i getting these errors

This is a discussion on y am i getting these errors within the C++ Programming forums, part of the General Programming Boards category; i tryed adding iostream as a headder file but i get 60 more error messages 1>c:\documents and settings\robert dobler\my documents\visual ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    12

    y am i getting these errors

    i tryed adding iostream as a headder file but i get 60 more error messages
    1>c:\documents and settings\robert dobler\my documents\visual studio 2005\projects\pro3\source1.cpp(15) : error C2065: 'cout' : undeclared identifier
    1>c:\documents and settings\robert dobler\my documents\visual studio 2005\projects\pro3\source1.cpp(16) : error C2065: 'cin' : undeclared identifier
    1>c:\documents and settings\robert dobler\my documents\visual studio 2005\projects\pro3\source1.cpp(32) : warning C4244: '=' : conversion from 'const double' to 'int', possible loss of data
    1>c:\documents and settings\robert dobler\my documents\visual studio 2005\projects\pro3\source1.cpp(36) : warning C4244: '=' : conversion from 'const double' to 'int', possible loss of data
    1>c:\documents and settings\robert dobler\my documents\visual studio 2005\projects\pro3\source1.cpp(40) : warning C4244: '=' : conversion from 'const double' to 'int', possible loss of data
    Code:
    //Robert Dobler
    #include <iomanip>
    #include <string>
    using namespace std;
    int main ()
    { 
    	int yearsofservice,yearhired,oldsalary,code,newsalary,salaryincrease;
    	int numfaculty,totsalaryincrease,avgsalaryincrease;
        const double ONE=.03;
    	const double TWO=.05;
    	const double THREE=.08;
    	const int YEAR=2007;
    	int facultycounter=1;
        string facultyname;
    	cout<<"How many faculty members are you inputting?:";
    		cin>>numfaculty;
    	do
    	{
    	 
    		cout<<"Input the members name:";
              getline(cin,facultyname);
    		  cout<<"Input the members year hired:";
    		  cin<<yearhired;
              yearsofservice=yearhired-YEAR;
    		  cout<<"Input the members old salary:";
    		  cin>>oldsalary;
    		  cout<<"Input the members code:";
              cin>>code;
    		  
    		  if (code==1)
    		  {
    			  newsalary=oldsalary*ONE;
    		   }
    		  else if (code==2)
    		  {
    			  newsalary=oldsalary*TWO;
    		  }
    		  else if (code==3)
    		  {
    			  newsalary=oldsalary*THREE;
    		  }
    		  salaryincrease=oldsalary-newsalary;
    		  cout<<"Robert Dobler\n\n\n";
    		  cout<<setw(15)<<"FAILNONE UNIVERSITY FACULTY SALARY REPORT FOR "<<YEAR;
    		  cout<<setw(10)<<"FACULTY"<<endl<<"NAME"<<endl<<"-------";
    		  cout<<setw(35)<<"YEARS OF"<<endl<<"SERVICE"<<endl<<endl<<"-------";
    		  cout<<setw(45)<<"OLD SALARY"<<endl<<"---";
    		  cout<<setw(55)<<"NEW SALARY"<<endl<<"------";
    		  cout<<setw(65)<<"SALARY"<<endl<<"INCREASE"<<endl<<"-------";
    		  cout<<setw(10)<<facultyname<<setw(35)<<yearsofservice<<setw(45)<<oldsalary;
    	      cout<<setw(55)<<newsalary<<setw(65)<<salaryincrease;
    	}while (facultycounter++ <numfaculty);
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> i tryed adding iostream as a headder file but i get 60 more error messages

    The <iostream> header is not #include'd in that code.

    Also, please post replies in the same thread rather than starting a new one for the same question.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    12
    now i get theses error messages

    error C2001: newline in constant
    error C2015: too many characters in constant
    error C2006: '#include' : expected a filename, found 'constant'
    fatal error C1083: Cannot open include file: '': No such file or directory

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    It looks like you didn't type it correctly, but I can't tell exactly what's wrong because I can't see what you typed.

  5. #5
    Registered User
    Join Date
    Nov 2007
    Posts
    12
    im still getting these messages
    error C2001: newline in constant
    error C2015: too many characters in constant
    error C2006: '#include' : expected a filename, found 'constant'
    fatal error C1083: Cannot open include file: '': No such file or directory
    Code:
    #include <iomanip>
    #include <string>
    #include'd <iostream>
    using namespace std;
    int main ()
    { 
    	int yearsofservice,yearhired,oldsalary,code,newsalary,salaryincrease;
    	int numfaculty,totsalaryincrease,avgsalaryincrease;
        const double ONE=.3;
    	const double TWO=.5;
    	const double THREE=.8;
    	const int YEAR=2007;
    	int facultycounter=1;
        string facultyname;
    	cout<<"How many faculty members are you inputting?:";
    		cin>>numfaculty;
    	do
    	{
    	 
    		cout<<"Input the members name:";
              getline(cin,facultyname);
    		  cout<<"Input the members year hired:";
    		  cin<<yearhired;
              yearsofservice=yearhired-YEAR;
    		  cout<<"Input the members old salary:";
    		  cin>>oldsalary;
    		  cout<<"Input the members code:";
              cin>>code;
    		  
    		  if (code==1)
    		  {
    			  newsalary=oldsalary*ONE;
    		   }
    		  else if (code==2)
    		  {
    			  newsalary=oldsalary*TWO;
    		  }
    		  else if (code==3)
    		  {
    			  newsalary=oldsalary*THREE;
    		  }
    		  salaryincrease=oldsalary-newsalary;
    		  cout<<"Robert Dobler\n\n\n";
    		  cout<<setw(15)<<"FAILNONE UNIVERSITY FACULTY SALARY REPORT FOR "<<YEAR;
    		  cout<<setw(10)<<"FACULTY"<<endl<<"NAME"<<endl<<"-------";
    		  cout<<setw(35)<<"YEARS OF"<<endl<<"SERVICE"<<endl<<endl<<"-------";
    		  cout<<setw(45)<<"OLD SALARY"<<endl<<"---";
    		  cout<<setw(55)<<"NEW SALARY"<<endl<<"------";
    		  cout<<setw(65)<<"SALARY"<<endl<<"INCREASE"<<endl<<"-------";
    		  cout<<setw(10)<<facultyname<<setw(35)<<yearsofservice<<setw(45)<<oldsalary;
    	      cout<<setw(55)<<newsalary<<setw(65)<<salaryincrease;
    	}while (facultycounter++ <numfaculty);
    	return 0;
    }

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Code:
    #include'd <iostream>

  7. #7
    Registered User
    Join Date
    Nov 2007
    Posts
    12

    i still need help error C2001: newline in constant

    i did add
    Code:
    #include'd <iostream>
    but i still get the following error and warning messages
    error C2001: newline in constant
    error C2015: too many characters in constant
    error C2006: '#include' : expected a filename, found 'constant'
    fatal error C1083: Cannot open include file: '': No such file or directory
    Code:
    //Robert Dobler
    #include <iomanip>
    #include <string>
    #include'd <iostream>
    using namespace std;
    
    int main ()
    { 
    	int yearsofservice,yearhired,oldsalary,code,newsalary,salaryincrease;
    	int numfaculty,totsalaryincrease,avgsalaryincrease;
    	const int YEAR=2007;
    	int facultycounter=1;
        string facultyname;
    	cout<<"How many faculty members are you inputting?:";
    		cin>>numfaculty;
    	do
    	{
    	 
    		cout<<"Input the members name:";
              getline(cin,facultyname);
    		  cout<<"Input the members year hired:";
    		  cin<<yearhired;
              yearsofservice=yearhired-YEAR;
    		  cout<<"Input the members old salary:";
    		  cin>>oldsalary;
    		  cout<<"Input the members code:";
              cin>>code;
    		  switch (code)
    		  {
    		  case 1:  newsalary=oldsalary*.03;
    		  case 2:  newsalary=oldsalary*.05;
    		  case 3:  newsalary=oldsalary*.08;
    			  break;
    		  default: cout<<"You did not type any code in!!!";
    		  }
    		  
    		 
    		  salaryincrease=oldsalary-newsalary;
    	
    	}while (facultycounter++ <numfaculty);
    	return 0;
    }
    can some one please tell me y i get these errors and how to fix them PLEASE!! does the program look ok otherwise?

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    no no without the 'd

  9. #9
    Registered User
    Join Date
    Nov 2007
    Posts
    12
    ya i found the problem here it is
    cin<<yearhired;

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    So your program now compiles, when you select "Build Solution" from the "Build" menu?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  11. #11
    Registered User
    Join Date
    Nov 2007
    Posts
    12

    its compiling and running

    the program is now compiling and running im still having a problem listing multiple the output data im stuck and i don;t know what to do
    Code:
    #include <iomanip>
    #include <string>
    #include <iostream>
    using namespace std;
    
    int main ()
    { 
    	int yearsofservice,yearhired,oldsalary,code;
    	int numfaculty,totsalaryincrease,avgsalaryincrease;
    	int facultycounter=1;
    	  double newsalary;
    	  double salaryincrease;
    	    const int YEAR=2007;
               string fname;
    	       string lname;
    	           cout<<"How many faculty members are you inputting?:";
    		           cin>>numfaculty;
    	do
    	{
    	
    		  cout<<"Input the members name:";
    		  cin>>fname>>lname;
    		  cout<<"Input the members year hired:";
    		     cin>>yearhired;
              cout<<"Input the members old salary:";
    		     cin>>oldsalary;
    		  cout<<"Input the members code:";
                 cin>>code;
    		  switch (code)
    		  {
    				case 1:  salaryincrease=oldsalary*(.03);
    					break;
    				case 2:  salaryincrease=oldsalary*(.05);
    					break;
    				case 3:  salaryincrease=oldsalary*(.08);
    					break;
    				default: cout<<"You did not type any code in!!!";
    		  }
    		        newsalary=salaryincrease+oldsalary;
    		        yearsofservice=YEAR-yearhired;
    	}while (facultycounter++ <numfaculty);
    cout<<"Robert Dobler\n\n\n";
    cout<<setw(57)<<"FAILNONE UNIVERSITY FACULTY SALARY REPORT FOR "<<YEAR<<endl<<endl<<endl<<endl;
    cout<<setw(10)<<"FACULTY"<<setw(17)<<"YEARS OF"<<setw(11)<<"OLD"<<setw(11)<<"NEW"<<setw(17)<<"SALARY"<<endl;
    cout<<setw(8)<<"NAME"<<setw(19)<<"SERVICE"<<setw(13)<<"SALARY"<<setw(11)<<"SALARY"<<setw(16)<<"INCREASE"<<endl;
    cout<<setw(10)<<"-------"<<setw(17)<<"--------"<<setw(13)<<"------"<<setw(11)<<"------"<<setw(16)<<"--------"<<endl;
    cout<<fname<<lname<<setw(12)<<yearsofservice<<setw(16)<<oldsalary<<setw(11)<<newsalary<<setw(14)<<salaryincrease<<endl;
    		return 0;
    }
    i have to list several outputs st once and it only lets me list the newest inputs i enter in

  12. #12
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475
    That code is quite hard to read. It may help if you added a little whitespace to ease readability and it will help you greatly when it comes to debugging the code. If it's easier on the eyes it's easier on the mind
    I'm just trying to be a better person - My Name Is Earl

  13. #13
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,490
    You can format a long line like this if you want.
    Code:
    cout << setw(10) << "FACULTY"
         << setw(17) << "YEARS OF"
         << setw(11) << "OLD"
         << setw(11) << "NEW"
         << setw(17) << "SALARY"
         << endl;
    Also, set your editor to use spaces only, and set a "soft" tab stop of 4 spaces. Mixing spaces and real TAB characters makes for a messy post, even if your IDE can sort it out (HTML can't).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  14. #14
    Registered User
    Join Date
    Nov 2007
    Posts
    12
    yes but the output is so post to look like this


    How many faculty members are you inputting?:1
    Input the members name:Rjohn doe
    Input the members year hired:1989
    Input the members old salary:55200
    Input the members code:2



    FAILNONE UNIVERSITY FACULTY SALARY REPORT FOR 2007



    FACULTY YEARS OF OLD NEW SALARY
    NAME SERVICE SALARY SALARY INCREASE
    ------- -------- ------ ------ --------
    john doe 18 55200 57960 2760

  15. #15
    Registered User
    Join Date
    Nov 2007
    Posts
    12
    How many faculty members are you inputting?:1
    Input the members name:John doe
    Input the members year hired:1989
    Input the members old salary:55200
    Input the members code:2



    FAILNONE UNIVERSITY FACULTY SALARY REPORT FOR 2007



    FACULTY YEARS OF OLD NEW SALARY
    NAME SERVICE SALARY SALARY INCREASE
    ------- -------- ------ ------ --------
    John doe 18 55200 57960 2760
    the last post didn;t come out the way it was sopoed to maybe this one will and if it doesn;t i hope u understand how it is soposed to be posed

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  2. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  3. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  4. Unknown Errors in simple program
    By neandrake in forum C++ Programming
    Replies: 16
    Last Post: 04-06-2004, 02:57 PM
  5. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21