I ran your code and minus the #include for everything ran perfectly. The only solutions I've seen before was to restart your IDE and see if that remedies your issue, maybe start a new project and copy paste your code into that main.cpp. Pls write a C code to read an integer value for score (0-100) and print the correct letter grade based on the following: below 50 should print F and 50-59 should print C,60-69 should print B, 70-79 should print B+, 80-89 should print A, then 90-100 should print A+. Tnks pls I nid it in C program. Mar 18, 2012 Employees Salary in c. GitHub Gist: instantly share code, notes, and snippets.
- C Programming Tutorial
- C Programming useful Resources
- Selected Reading
An if statement can be followed by an optional else Dune 3 vst download. statement, which executes when the Boolean expression is false.
Syntax
The syntax of an if..else statement in C programming language is −
If the Boolean expression evaluates to true, then the if block will be executed, otherwise, the else block will be executed.
C programming language assumes any non-zero and non-null values as true, and if it is either zero or null, then it is assumed as false value.
Flow Diagram
Example
When the above code is compiled and executed, it produces the following result − Bass one vst free download pc.
If..else if..else Statement
An if statement can be followed by an optional else if..else statement, which is very useful to test various conditions using single if..else if statement.
When using if..else if.else statements, there are few points to keep in mind −
- An if can have zero or one else's and it must come after any else if's.
- An if can have zero to many else if's and they must come before the else.
- Once an else if succeeds, none of the remaining else if's or else's will be tested.
Syntax
The syntax of an if..else if..else statement in C programming language is −
Example
When the above code is compiled and executed, it produces the following result −
Dev C++ Programs
c_decision_making.htm
employeesalary
Input Processing Output |
1) Enter Code |
1) Manager:Salary 2) if(code1) Manager Salary |
Print Manager Salary |
2) HourlyWorker: 3) if(code2) HourlyW ... |
Enter Hours |
if(hours<=40) |
hours calculate: hours*rate |
rate else |
salary = 40.0 * hrRate + ( hours - 40 ) * hrRate * 1.5; |
3) Commisions 4) if(code3) CommissionW.. |
Enter Sale |
sale calculate: (sale*0.57)+250 |
5.7% print |
4) PieceWorker: 5) if(code4) PieceW.... |
numOfProduct Enter number of product |
Rate Enter rate |
calculate:rate*numOfProduct |
5) PayCode(1= Manager; 2=hourly worker; 3=Commissions Worker; 4=pieceworker) */ |
#include <cstdlib> |
#include <iostream> |
#include <iomanip> |
using namespace std; |
class EmployeeSalary |
{ |
public: |
/* hourly workers*/ |
double CalculateHourlySalary(int hrRate, int hours) |
{ |
if ( hours <= 40 ) |
salary = hours * hrRate; |
else |
salary = 40.0 * hrRate + ( hours - 40 ) * hrRate * 1.5; |
return salary; |
} |
/*Commission workers*/ |
double getCommissionHourlySalary(double sale) |
{ |
sale =(sale* 0.057 )+ 250; |
return sale; |
} |
/* Piece Workers*/ |
double getPieceWorkerHourlySalary(int product, int rate) |
{ |
int pro = product * rate; |
return pro; |
} |
void instruct() |
{ |
cout<<'The Purpose of this Program is to calculate each employees pay rate by entering the employee paycode ' |
'for example, when the user type in 1, it will calculate the' |
'Manager salary, 2 for hourlyWorkers,' |
' 3 for Commission Workers and 4 for PieceWorkers ' |
'and the program itself will do ' |
'the calculation for that particular employee' |
' and when ever the user Enter -1 as the PayCode ,program will executed.'<<endl; |
} |
private: |
double salary; |
}; |
int main() |
{ |
EmployeeSalary salary; |
int paycode; |
double sal; |
int hrRate; |
int product; |
int rate; |
int hours; |
int sale; |
salary.instruct(); |
cout<<endl<<endl; |
cout<<' *******************************************'<<endl; |
cout<<' %%%%%%% [-1] To End The Program: %%%%%%%%'<<endl; |
cout<<' *******************************************'<<endl; |
cout<<' **** [1] Manager PayCode: ******'<<endl; |
cout<<' **** [2] Hourly worker PayCode: ******'<<endl; |
cout<<' **** [3] Commission worker PayCode: ******'<<endl; |
cout<<' **** [4] Piece worker PayCode: ******'<<endl; |
cout<<' *******************************************'<<endl; |
while(paycode!=-1) |
{ |
cout<<endl; |
cout<<' Enter PayCode:'<<' '<<setiosflags( ios::fixed | ios::showpoint ); |
cin>>paycode; |
cout<<'*******************************************'<<endl; |
cout<<endl; |
if(paycode1) |
{ |
/*Manager Fixed salary */ |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'^^^^ Manager PayCode Has been selected ^^^^'<<endl; |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'Enter Salary: '; |
cin>>sal; |
cout<<'Manager's salary is:$ '<<setprecision(2)<<sal<<endl; |
cout<<endl; |
cout<<endl; |
system('pause'); |
} |
if(paycode2) |
{ |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'^^^^^^^^ Hourly Worker PayCode ^^^^^^^^'<<endl; |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'Enter Hour Rate:$ '; |
cin>>hrRate; |
cout<<'Enter hours worked: '; |
cin>>hours; |
cout<<'Hourly worker's salary is:$ '<<setprecision(2)<<salary.CalculateHourlySalary(hrRate,hours)<<endl; |
cout<<endl; |
system('pause'); |
} |
if(paycode3) |
{ |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'^^^^^^^ Commission Workers PayCode ^^^^^^'<<endl; |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'Enter weekly sale: '; |
cin>>sale; |
cout<<'Commission worker's hourly is:$ '<<setprecision(2)<<salary.getCommissionHourlySalary(sale)<<endl; |
cout<<endl; |
system('pause'); |
} |
if(paycode4) |
{ |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'^^^^^^^^^^ Piece Worker PayCode ^^^^^^^^^'<<endl; |
cout<<'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'<<endl; |
cout<<'Enter Number of product: '; |
cin>>product; |
cout<<'Enter rate per each pieces sold:$ '; |
cin>>rate; |
cout<<'Piece worker's salary: '<<setprecision(2)<<salary.getPieceWorkerHourlySalary(product,rate)<<endl; |
system('pause'); |
} |
else |
cout<<'Input Error'<<endl; |
} |
return 0; |
} |
Grading System Code In Dev C For Pc
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment