In: Computer Science
A Private Poly Clinic in City wish to develop software to automate their Patient Monitoring system for storing the details of the patients visited the clinic. Develop a system to meet the following requirements:
patients and fees to be paid by them as shown in the below table. Calculate the
total fees paid by the female and male patients separately and display them
with appropriate statements.
Patient Id |
Fees in (OMR) |
Gender |
P001 |
15 |
M |
P002 |
10 |
F |
P003 |
20 |
M |
P004 |
8 |
F |
P005 |
12 |
M |
Sample Output : Name : Khamis Al Araimi
Acromatic String: AKAA
Hello student in above stated question we have 4 parts as mentioned and i am going to solve one by one each. If you have any query please let me know and rate the answer
1). Displaying total fees paid by male and female patients along with there gender
Flow chart
Algorithm
read number of patients
nop=n
for i=1 to nop
{
read patients gender
read patients fee
if gender equals to male
fee_of_male increment by 1
else
fee_of_female increment by 1
}
display male patients fee
display female patients fee
C Program
#include <stdio.h>
int main()
{ char gender;
float fee=0,total_fee_male=0,total_fee_female=0;
int nop; // total number of patients
printf("enter a number of patients \n");
scanf("%d",&nop);
for (int i=0;i<nop;i++)
{
printf("Enter patients gender\n");
scanf("%c",&gender);
printf("Enter of patients fee\n");
scanf("%f",&f);
if ((gender=='m')||(gender=='M'))
{
total_fee_male= total_fee_male + fee;
}
else
{
total_fee_female = total_fee_female + fee;
}
}
printf("fees paid by male %f /n", total_fee_male);
printf("fees paid by female %f /n", total_fee_male);
return 0;
}
2) Fees in ascending order
Flow chart
Algorithm
read number of patients
nop =n
for i =1 to nop
{
read patients fees
}
for i=1 to nop
{
for j=i+1 to nop
{ temp= fee[i]
fee[i]= fee[j]
fee[j] = fee[i]
}
}
display fees in ascending order
C Program
#include <stdio.h>
int main ()
{int n,i,j;
printf ("enter a no.of patients \n");
scanf ("%d", &n);
float f[n],t;
for (i = 0; i < n; i++)
{
printf("enter a fee patients \n");
scanf("%f",&f[i]);
}
for (i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(f[i]>f[j])
{
t=f[i];
f[i]=f[j];
f[j]=t;
}
}
}
printf("fees are arranged in ascending order \n");
for ( i = 0; i < n; i++)
{
printf("%f \n",f[i]);
}
return 0;
}
3) Acromatic string
Flowchart
Algorithm
var i=0
read name of patient
display name [0]
while name[i] not equal to null
{
if name[i] equals to white space
display name[i]
increment i by 1
}
C program
#include <stdio.h>
int main()
{
char name[100];
int i=0;
printf("Enter name of a patient \n");
gets(name);
printf("%c",name[0]);
while (name [i]!='\0')
{
if(name[i]==' ')
{
i++;
printf("%c",name[i]);
}
i++;
}
getch();
return 0;
}
4) 15% discount
Flow chart
C program
#include <stdio.h>
void discount (int a, float f)
{
if (a>60)
{ float d;
d=f * 0.15;
f=f-d;
printf("fees to be paid after discount \n");
printf("%f",f);
}
else
{
printf("fees to be paid %f \n", f);
printf("%f",f);
}
}
int main()
{ void discount(int a,float f);
int age;
float fee;
printf("Enter a patients age \n");
scanf("%d",&age);
printf("Enter a patients fee \n");
scanf("%f",&fee);
void discount(age,fee);
return 0;
}