write a program to accept the salaries of 10 employees from the user and display them in descending order for all the employees,if the user enters zero, the program should display the message"the amount should be greater than zero" and accept the value again.
#include <iostream>
using namespace std;
class Employee
{
float salary[10];
public:
void sortdata()
{
int ctr;
for(ctr=0;ctr<10;ctr++)
{
cout<<"enter the salary:";
cin>>salary[ctr];
if(salary[ctr] == 0)
{
cout<<"salary should be greater than zero"<<endl;
continue;
}
}
int sal=0;
while (sal<9)
{
float temp;
if(salary[sal]<salary[sal+1])
{
temp=salary[sal];
salary[sal]=salary[sal+1];
salary[sal+1]=temp;
sal=0;
continue;
}
sal++;
}
}
void display()
{
for(int sal=0;sal<10;++sal)
{
cout<<"element"<<sal<<":"<<salary[sal]<<endl;
}
}
};
int main()
{
Employee E;
E.sortdata();
E.display();
return 0;
}
so i wrote the program but the last part of the question isn't working, if the user enters zero,the program should display the message"the amount should be greater than zero" and accept the values again. whats wrong with the code.:(