# various wages calculation

• 11-30-2012
zaharith123
various wages calculation
Hi guys.Im really2 new in c++ programming i hope u guys can help me.here`s the question,calculate the wages for the employee`s and display various wages information.the program should accept an employee number,base pay rate per hour,and the number of hours worked.here`s my attempt

Code:

```#include <iostream.h>  int empNum;    //employee`s number  int payRate;    //base pay rate per hour  int hours;      //hours worked  float overtime; //amount paid with overtime hours  float netWage;  //net wages of employee`s  float aveWage;  //average wages paid to the employee`s  float miniWage; //minimun wages paid to the employee`s  float totWage;  //total wages paid to the employee`s int main() {     cout << "Enter employee`s number:";     cin >> empNum     do     {       cout << "Enter hours worked:";       cin >> hours;       cout << "Enter base pay rate per hour:";       cin >> payRate;     if (hours > 40){     overtime = payRate * 1.5;   }   else     netWage = hours + payRate;     totWage = hours + payRate;     aveWage = totWage/2;     miniWage = smallest netWage;   }while (empNum <= 2);   return 0;  }```

seriously i`m new in programming,thanks for any help.
• 12-01-2012
Salem
Code:

```  else     netWage = hours + payRate;     totWage = hours + payRate;     aveWage = totWage/2;     miniWage = smallest netWage;```
Despite your indentation, it's only netWage which is part of the else statement.

If you want all 4 lines to be part of the else, you need braces.
Code:

```  else {     netWage = hours + payRate;     totWage = hours + payRate;     aveWage = totWage/2;     miniWage = smallest netWage;   }```
Until you're absolutely confident in knowing when braces are optional, you don't lose anything by using braces all the time.
Using them all the time gives you one less thing to worry about.

> miniWage = smallest netWage;
This won't work - what is smallest?