C++ program in Bloodshed Dev C++, I was told by the compiler log that I have 1 error and I cant figure it out!

#include <iostream.h>
int main () {
int employeeid;
int hoursworked;
float hourlyrate, grosspay, taxamount, netpay;
float const TAXRATE = 0.10;
cout << "Enter The Employee ID: ";
cin >> employeeid;
cout << "Enter The Hours Worked: ";
cin >> hoursworked;
cout << "Enter The Hourly Rate: ";
cin >> hourlyrate;
grosspay = hoursworked * hourlyrate;
taxamount = grosspay * TAXRATE;
netpay = grosspay - taxamount;
cout << "EMPLOYEE ID IS " << employeeid << endl;
cout << "THE HOURS WORKED ARE " << hoursworked << endl;
cout << "THE HOURLY RATE IS " << hourlyrate << endl;
cout << "THE GROSSPAY IS " << grosspay << endl;
cout << "THE TAXAMOUNT IS " << taxamount << endl;
cout << "THE NETPAY IS " << netpay << endl;
return 0;
}//MAIN
6
Contributors
12
Replies
13
Views
9 Years
Discussion Span
Last Post by Nick Evan

Hey hapiscrap:

Make the following changes:

1) Change #include <iostream.h> to #include <iostream>
2) After the #include <iostream> line and before int main(), put: using namespace std;

These small changes should help you compile your program and run it. Another problem you might have is that after you type in the inputs, the window will close immediately (Before you can see the results). To fix this, declare a dummy variable (ex. int i;) and before the return 0 line, put in: cin >> i. By putting cin >> i, this will make the window visible and leave it up so you can see the output. To exit out of the window, you can press: CTRL + C.

Hope this helps!

> I was told by the compiler log that I have 1 error and I cant figure it out!

> I was told by the compiler log that I have 1 error and I cant figure it out!

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\payroll.cpp" -o "C:\Dev-Cpp\payroll.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
C:\Dev-Cpp\payroll.cpp: In function int main()':
C:\Dev-Cpp\payroll.cpp:24: error: expected ;' before "return"

Execution terminated

sorry salem i used the changes above your post an these were the error results

Did you add the changes suggested by Compton11?

Use code=cpp for better code tags, as that gives us line numbers as well.

here is the code and compiler log on bloodshed dev c++,

#include <iostream>
using namespace std;
int main() {
int employeeid;
int hoursworked;
float hourlyrate, grosspay, taxamount, netpay;
float const TAXRATE = 0.10;
cout << "Enter The Employee ID: ";
cin >> employeeid;
cout << "Enter The Hours Worked: ";
cin >> hoursworked;
cout << "Enter The Hourly Rate: ";
cin >> hourlyrate;
grosspay = hoursworked * hourlyrate;
taxamount = grosspay * TAXRATE;
netpay = grosspay - taxamount;
cout << "EMPLOYEE ID IS " << employeeid << endl;
cout << "THE HOURS WORKED ARE " << hoursworked << endl;
cout << "THE HOURLY RATE IS " << hourlyrate << endl;
cout << "THE GROSSPAY IS " << grosspay << endl;
cout << "THE TAXAMOUNT IS " << taxamount << endl;
cout << "THE NETPAY IS " << netpay << endl;
system("pause")
return 0;
}//MAIN

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\payroll.cpp" -o "C:\Dev-Cpp\payroll.exe" -g3 -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
C:\Dev-Cpp\payroll.cpp: In function int main()':
C:\Dev-Cpp\payroll.cpp:24: error: expected ;' before "return"

Execution terminated

Which version of Dev-C++ are you using? I'm using version 4.9.9.2 and it's compiling and running perfectly. Another suggestion is to do some kind of exception handling. For instance, in the first input, if the user inputs anything other than an integer value, the program will terminate. It's smart to put some kind of error message in case the user provides an invalid input. Take out that system("pause") line and replace it with a cin >> i. You must declare the variable "i" first of course...If you still have a problem, let us know...

Use code=cpp .

That doesn't work. Needs to be [code=cplusplus]

system("pause")

code........

#include <iostream>
using namespace std;
int main() {
int employeeid;
int hoursworked;
float hourlyrate, grosspay, taxamount, netpay;
float const TAXRATE = 0.10;
cout << "Enter The Employee ID: ";
cin >> employeeid;
cout << "Enter The Hours Worked: ";
cin >> hoursworked;
cout << "Enter The Hourly Rate: ";
cin >> hourlyrate;
grosspay = hoursworked * hourlyrate;
taxamount = grosspay * TAXRATE;
netpay = grosspay - taxamount;
cout << "EMPLOYEE ID IS " << employeeid << endl;
cout << "THE HOURS WORKED ARE " << hoursworked << endl;
cout << "THE HOURLY RATE IS " << hourlyrate << endl;
cout << "THE GROSSPAY IS " << grosspay << endl;
cout << "THE TAXAMOUNT IS " << taxamount << endl;
cout << "THE NETPAY IS " << netpay << endl;
system("pause");
return 0;
}//MAIN

compiler log.......I recieved 2 errors

/mingw/lib/crt2.o(.text+0x167):crt1.c: undefined reference to __cpu_features_init'
collect2: ld returned 1 exit status

Execution terminated

You need to figure out how to read before doing anything else.

I told you exactly what to do many hours ago, yet here you are again with exactly the same code in YET ANOTHER NEW thread.

Off-topic:

That doesn't work. Needs to be [code=cplusplus]

It works for me:
cpp:

std::cout << a << "something\n";

cplusplus:

std::cout << a << "something\n";`

I always use the first because I'm to damn lazy to type 'cplusplus' everytime I post code :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.