A company decides to increase its employees salaries based o

A company decides to increase its employees\' salaries based on their current salaries range. The following table contains the increment percentage based on the current salary rang. Using switch, write a C program asked the user for the salary, and then calculates and prints the new salary after applying the increment. Rewrite the program so that its runs continuously. Rewrite the program so that it should exist if the user entered a negative salary.

Solution

#include<stdio.h>
#include<conio.h>
int salaryOption(int);
int main()
{
   int salary;
printf(\"Enter Salary:\");
scanf(\"%d\",&salary);
int choice;
//printf(\"Choice %d\",choice);
choice = salaryOption(salary);// calling function


switch(choice){ // based on choice swithch case exectues and prints effected salary
           case 1:
               printf(\"Effected Salary:%d\",salary+(salary*3)/100);
               break;
           case 2:
printf(\"Effected Salary:%d\",salary+(salary*2)/100);
               break;
case 3:
               printf(\"Effected Salary:%d\",salary+(salary*1.5)/100);
               break;
       case 4:
               printf(\"Effected Salary:%d\",salary+(salary*1)/100);
               break;
           default:
               printf(\"Enter correct Choice..!\");

}
  

   getchar();
   getchar();
return 0;
}
int salaryOption(int sal){ // fucntion to return option based on salary table
   if(sal>0 || sal<5000){
       return 1;
   }else if (sal>=5000 || sal <=7000){
       return 2;
   }else if (sal>7000 || sal <=10000){
       return 3;
       }
   else if (sal>10000){
           return 4;
}
}

 A company decides to increase its employees\' salaries based on their current salaries range. The following table contains the increment percentage based on th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site