Write a C program that displays the fees that a student needs to pay at the end of the semester. Use switch statement.

Input Format:
The first line of the input consists of a character from the set {A, B, C, D}. A corresponds to a day scholar student with the required attendance percentage. B  corresponds to a day scholar student without the required attendance percentage. C corresponds to a  hostel student with the required attendance percentage. D corresponds to a hostel student without the required attendance percentage.
The second line of the input consists of an integer which corresponds to the number of regular papers for which the student is appearing in the examination.
The third line of the input consists of an integer which corresponds to the fee to be paid per regular paper.
The fourth line of the input consists of an integer which corresponds to the number of backup(arrear) papers for which the student is appearing in the examination.
The fifth line of the input consists of an integer which corresponds to the fee to be paid per arrear paper.

 Output Format:
The output consists of a single line. Refer to Sample output for format details.
[ There is a condonation fee of Rs. 5000 for lack of attendance and the hostel students need to pay the last month mess bill of Rs.1500 along with the examination fee.]

 Sample Input 1:
A
5
100
1
200
Sample Output 1:
The fee to be paid is Rs.700

Sample Input 2:
B
5
100
1
200
Sample Output 2:
The fee to be paid is Rs.5700

Sample Input 3:
C
5
100
1
200
Sample Output 3:
The fee to be paid is Rs.2200

Sample Input 4:
D
5
100
1
200
Sample Output 4:
The fee to be paid is Rs.7200


Program Code:
#include<stdio.h>
int main()
{
    char ch;
    int nop, fop, bk,fbk, ans;
    scanf("%c",&ch);
    scanf("%d%d%d%d", &nop, &fop, &bk, &fbk);
    switch(ch)
    {
        case 'A' : 
        ans = nop*fop+bk*fbk;
        printf("The fee to be paid is Rs. %d", ans);
        break;
        case 'B' : 
        ans = nop*fop+bk*fbk+5000;
        printf("The fee to be paid is Rs. %d", ans);
        break;
        case 'C' : 
        ans = nop*fop+bk*fbk+1500;
        printf("The fee to be paid is Rs. %d", ans);
        break;
        case 'D' : 
        ans = nop*fop+bk*fbk+6500;
        printf("The fee to be paid is Rs. %d", ans);
        break;
    }
    return 0;
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: