Monday, August 20, 2018

GROSS SALARY

  • Problem Description

    In a company an emplopyee is paid as under: If his basic salary is less than Rs. 1500, then HRA = 10% of base salary and DA = 90% of basic salary.

    If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. 

    If the Employee's salary is input, write a program to find his gross salary.

    NOTE: Gross Salary = Basic Salary+HRA+DA

    Input

    The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer salary.

    Output

    Output the gross salary of the employee.

    Constraints
    1 < T< 1000
    1< salary < 100000
  • CODING ARENA
  • #include<stdio.h>
     
    int main(){
        int t,n;
        scanf("%d",&t);
        while(t){
            scanf("%d",&n);
            if(n<1500)
                printf("%.0f\n",(float)n*2);
            else
                printf("%.0f\n",(float)n*1.98+500.00);
     
            t--;
        }
     
    return 0;
    }
     
  • Test Case 1

    Input (stdin)
    3
    
    1400
    
    2500
    
    3000
    
    
    Expected Output
    2800
    
    5450
    
    6440
  • Test Case 2

    Input (stdin)
    2
    
    500
    
    1500
    
    
    Expected Output
    1000
    
    3470

No comments:

Post a Comment