C Programming – HackerRank Solution | KCCI Contract |

Write a Modular C Programming code to find out KCCI Contract, Help KCCI to decide the payment of the player according to the contract

For every year KCCI announces its Central contract to the player actively performing in the sport will be allocated a grade and he will be paid according to the grade allocated. The committee consisting of the President, Secretary, and Chief selector is going to decide the list of players.

It’s a ritual that happens every year but this year it brought a dramatic scene to the cricket environment. The Players currently for team India will be taken to contract to play for a certain period of time and categorized into 3 groups with different cash returns in each group.

This categorization depends upon their average runs in all games in different formats. By keeping this in concern players are positioned in A, B, and C grades.

image

Help KCCI to decide the payment of the player according to the contract. And if the average in any contract is greater than 40 then give a 10% bonus.

Input Format

Contract and average of the player

Constraints

The contract should be A/B/C.

The average should be between 0 to 50 for any contract.

Output Format

Display the payment of the player.

Sample Input 0

A 46

Sample Output 0

55000000

Sample Input 1

D 35

Sample Output 1

Invalid Contract Grade

Refer : C Programming HackerRank all solutions for Loops | Arrays | strings

 

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main() {
    int avg;
    char grade;
    int payment;
    scanf("%c%d",&grade,&avg);
    if(grade=='A')
    {
        if(avg<30 && avg>0)
        {
            payment=20;
        }
        else if(avg>30 && avg<36)
 { 
payment=50;
 } 
else if(avg>35 && avg<41) 
{
 payment=100;
 } 
else if(avg>40 && avg<46) 
{
 payment=200;
 } 
else if(avg>45 )
        {
            payment=500;
        }
        if(avg>40)
        {
            payment=payment+(payment*0.1);
        }
        printf("%d00000",payment);
    }
    else if(grade=='B')
    {
        if(avg<30) 
{ 
payment=10;
 } 
else if(avg>30 && avg<36)
{ 
payment=40; 
} 
else if(avg>35 && avg<41)
 { 
payment=80; 
}
 else if(avg>40 && avg<46) 
{ 
payment=100; 
} 
else if(avg>45)
        {
            payment=200;
        }
        if(avg>40){
            payment=payment+(payment*0.1);
        }
        printf("%d00000",payment);
    }
    else if(grade=='C')
    {
        if(avg<30)
 { 
payment=5; 
} 
else if(avg>30 && avg<36)
 { 
payment=30; 
}
 else if(avg>35 && avg<41)
 { 
payment=60; 
} 
else if(avg>40 && avg<46)
 { 
payment=80; 
} 
else if(avg>45)
        {
            payment=100;
        }  
        if(avg>40){
            payment=payment+(payment*0.1);
        }
        printf("%d00000",payment);
    }
    else{
        printf("Invalid Contract Grade");
    }
    return 0;
}


OUTPUT

Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

A 46
Your Output (stdout)

55000000
Expected Output

55000000

 

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University







Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!