Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main()
- {
- float salary_input,max_salary=0,min_salary=9999,total_salary=0;
- int totalSalaryBelow2k=0,count=0;
- char staff_input[30],max_staff[30],min_staff[30];
- cout<<"Please enter staff name (enter X to exit) : ";
- cin>>staff_input;
- //use strcmp utk compare between char array
- while(strcmp(staff_input,"X")){
- cout<<"Please enter salary : ";
- cin>>salary_input;
- //finding min salary and copying staff name in the variable
- if(salary_input<min_salary){
- min_salary=salary_input;
- strcpy(min_staff,staff_input);
- }
- //finding max salary and copying staff name in the variable
- if(salary_input>max_salary){
- max_salary=salary_input;
- strcpy(max_staff,staff_input);
- }
- //finding how much people with salary below rm2k
- if(salary_input<2000)
- totalSalaryBelow2k++;
- total_salary+=salary_input;
- count++;
- cout<<"Please enter staff name (enter X to exit) : ";
- cin>>staff_input;
- }//end of loop
- float average = total_salary/count;
- cout<<"\nHighest salary : "<<max_salary<<" ( "<<max_staff<<" )"<<endl;
- cout<<"Lowest salary : "<<min_salary<<" ( "<<min_staff<<" )"<<endl;
- cout<<"Average salary : "<<average<<endl;
- cout<<"Number of staff for salary below RM2000 : "<<totalSalaryBelow2k<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement