Monday 14 March 2016

FEES CALCULATOR


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 or 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

Code:
  #include<stdio.h>
int main()
{
  char s[1];
  int sum=0;
  int rpaper,rfee,arrear,afees;
  scanf("%s",s);
  scanf("%d",&rpaper);
  scanf("%d",&rfee);
  scanf("%d",&arrear);
  scanf("%d",&afees);
  sum=(rpaper*rfee)+(arrear*afees);
  switch(s[0])
  {
    case 'A':printf("The fee to be paid is Rs.%d",sum);
             break;
    case 'B':printf("The fee to be paid is Rs.%d",sum=sum+5000);
            break;
    case 'C':printf("The fee to be paid is Rs.%d",sum=sum+1500);
            break;
    case 'D': printf("The fee to be paid is Rs.%d",sum=sum+6500);
             break;
  }
  return 0;
}

    
  

2 comments: