Write a program that inputs employees code, names, and salaries of 10 employees in three arrays ‘code’, ‘name’, and ‘salary’ It computes the net salary. If the salary is 250000 or more, it deducts 13% of the salary. If the salary is 150000 or more but less than 250000, it deducts 1500 from the salary.
So let’s Write Code:
Let’s build logic First:
Code:
Write a program that inputs employees code, names, and salaries of 10 employees in three arrays ‘code’, ‘name’, and ‘salary’ It computes the net salary.
#include<iostream>
using namespace std;
main()
{
int emp_code[10], i;
float emp_salary[10], net_salary;
char emp_names[10][25];
i = 0;
while(i<=9)
{
cout<<endl<<"Enter record of employee : "<<i+1<<endl;
cout<<"Employee code : ";
cin>>emp_code[i];
cout<<"Employee name : ";
cin>>emp_names[i];
cout<<"Employee Salary : ";
cin>>emp_salary[i];
i++;
}
i = 0;
while(i<=9)
{
if(emp_salary[i] >=250000)
net_salary = emp_salary[i] - emp_salary[i] *10.0/100;
else if(emp_salary[i] >=150000)
net_salary = emp_salary[i] - 1500;
cout<<endl<<"Record of employee # "<<i+1<<endl;
cout<<"Employee code : "<<emp_code[i]<<endl;
cout<<"Employee name : "<<emp_names[i]<<endl;
cout<<"Employee Salary : "<<emp_salary[i]<<endl;
cout<<"Employee Net Salary : "<<net_salary;
cout<<endl;
i++;
}
}
Hope You will learn Something. Happy Coding.
Visit my YouTube Channel as Well😇 https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4
Click on the below Links for more Programming Exercises:
Conditional Structure Exercises: 👉https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/
Array Exercises: 👉https://myustaadg.com/category/programming-exercises/arrays-exercises/