First Method:
#include <stdio.h>
int main() {
float s,e;
char g;
printf("Enter salary, work experience & grade:");
scanf("%f %f %c",&s,&e,&g);
if(e>=5)
{
if(g=='A'||g=='a')
{
s=s*2;
}
else if(g=='B'||g=='b')
{
s=s*1.75;
}
else if(g=='C'||g=='c')
{
s=s*1.60;
}
else if(g=='D'||g=='d')
{
s=s*1.50;
}
else
{
s=s*1.25;
}
}
else
{
s=s*1.15;
}
printf("Net Salary=%.2f",s);
}
Second Method:
#include <stdio.h>
int main() {
float e,s;
char g;
printf("Enter experience,salary and grade:");
scanf("%f %f %c",&e,&s,&g);
if(e>=15)
{
if(g=='A'||g=='a')
{
s=s*2;
}
else if(g=='B'||g=='b')
{
s=s*1.75;
}
else if(g=='C'||g=='c')
{
s=s*1.60;
}
}
else if(e>=10)
{
s=s*1.5;
}
else if(e>=5)
{
s=s*1.4;
}
else
{
s=s*1.25;
}
printf("Net Salary=%.2f",s);
}
No comments:
Post a Comment