Problem Description
Write a 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.]
Mandatory:
You should use Switch case to get 100% evaluation
CODING
ARENA::
#include
<stdio.h>
int
main()
{
char s[1];
int sum=0;
int rpaper,rfree,arrear,afees;
scanf("%s",s);
scanf("%d",&rpaper);
scanf("%d",&rfree);
scanf("%d",&arrear);
scanf("%d",&afees);
sum=(rpaper*rfree)+(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;
}
Test Case 1
Input (stdin)
A
5
100
1
200
Expected Output
The fee to be paid is Rs=700
Test Case 2
Input (stdin)
B
5
100
1
200
Expected
Output
The fee to be paid is Rs=5700
No comments:
Post a Comment