Thursday, July 30, 2009

C++ help! i am just a beginner - need help with my program please! i get some errors that i don't know how

this is my code:


#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;





using std::cout;


using std::cin;


using std::endl;


using std::fixed;


using std::setprecision;





int main()


{


//declare variables


int yearsCompany = 0;


int weekVac = 0;





//enter input


cout %26lt;%26lt; "Enter numbers of years of the employee: ";


cin %26gt;%26gt; yearsCompany;





//calculate and display the number of weeks due to an employee





cout %26lt;%26lt; fixed %26lt;%26lt; setprecision(2);





if (yearsCompany = 0)


cout %26lt;%26lt; "Years of vacation due: " %26lt;%26lt; weekVac = 0 %26lt;%26lt; endl;


else if (yearsCompany %26gt;= 1 %26amp;%26amp; yearsCompany %26lt;= 5)


cout %26lt;%26lt; "Years of vacation due: " %26lt;%26lt; weekVac = 1 %26lt;%26lt; endl;


else if (yearsCompany %26gt;= 6 %26amp;%26amp; yearsCompany %26lt;= 10)


cout %26lt;%26lt; "Years of vacation due: " %26lt;%26lt; weekVac = 2 %26lt;%26lt; endl;


else if (yearsCompany %26gt;= 11 )


cout %26lt;%26lt; "Years of vacation due: " %26lt;%26lt; weekVac = 3 %26lt;%26lt; endl;


else


cout %26lt;%26lt; "invalid years: " %26lt;%26lt; endl;


//end ifs


return 0;


} //end of main function

C++ help! i am just a beginner - need help with my program please! i get some errors that i don't know how
Start with something simple like the Hello World example.





#include %26lt;iostream.h%26gt;





main()


{


for(;;)


{


cout %26lt;%26lt; "Hello World! ";


}}
Reply:"cout %26lt;%26lt; "Years of vacation due: " %26lt;%26lt; weekVac = 0 %26lt;%26lt; endl;"





You can not set a variable in the cout statement.








You need to set it prior to use


No comments:

Post a Comment