Question

In: Computer Science

Hello sir can you explain me this code in details. void claimProcess() { int id; bool...

Hello sir can you explain me this code in details.

void claimProcess()

{

int id;

bool found = false;

system("cls");

printf("Enter patient ID for which you want to claim insurrence: ");

scanf("%d", & id);

int i;

for (i = 0; i < patientCount; i++)

{

if (patients[i].id == id)

{

found = true;

break;

}

}

if (found == false)

{

printf("subscriber not found\n");

return;

}

int numOfDaysHospitalized, suppliesCost, surgicalFee, otherCharges;

bool ICU;

printf("How many days were you haspitalized: ");

scanf("%d", & numOfDaysHospitalized);

int ICUFlag;

do {

printf("Select A Ward Type\n1-Normal Ward 2-ICU: ");

scanf("%d", & ICUFlag);

} while (ICUFlag < 1 || ICUFlag > 2);

if (ICUFlag == 2)

ICU = true;

else

ICU = false;

printf("Enter Cost of Supplies and Services: ");

scanf("%d", & suppliesCost);

printf("Enter Surgical Fees: ");

scanf("%d", & surgicalFee);

printf("Enter Other Charges: ");

scanf("%d", & otherCharges);

int ICUCharges = 0;

if (ICU == true)

{

if (patients[i].plan == 1)

ICUCharges = numOfDaysHospitalized * 120;

else if (patients[i].plan == 2)

ICUCharges = numOfDaysHospitalized * 150;

else

ICUCharges = numOfDaysHospitalized * 200;

} else

{

if (patients[i].plan == 1)

ICUCharges = numOfDaysHospitalized * 250;

else if (patients[i].plan == 2)

ICUCharges = numOfDaysHospitalized * 400;

else

ICUCharges = numOfDaysHospitalized * 700;

}

int totalClaimAmount = numOfDaysHospitalized + suppliesCost + surgicalFee + otherCharges + ICUCharges;

if (patients[i].annualClaim == true)

{

if (patients[i].age > 60)

{

printf("The subscriber age has exceeded the limit(60 Year), Not Eligible");

return;

}

}

int j;

for (j = 0; j < patientCount; j++)

{

if (claims[j].id == patients[i].id)

break;

}

int amountToBeBorne = 0;

if (totalClaimAmount <= claims[j].remaininigAmount)

{

claims[j].amountClaimed += totalClaimAmount;

claims[j].remaininigAmount -= totalClaimAmount;

} else

{

amountToBeBorne = totalClaimAmount - claims[j].remaininigAmount;

claims[j].amountClaimed += (totalClaimAmount - amountToBeBorne);

claims[j].remaininigAmount = 0;

printf("\n\nThe amount that can be claimed is less then the claim by subscriber. %d RM should be given by subscriber themselves\n", amountToBeBorne);

}

FILE * fp;

fp = fopen("claims.txt", "w");

for (int i = 0; i < patientCount; i++)

fprintf(fp, "%d,%d,%d,%d\n", claims[i].id, claims[i].claimedYear, claims[i].amountClaimed, claims[i].remaininigAmount);

fclose(fp);

printf("Subscriber ID: %d\nSubscriber Name: %s\nSubscriber Claimed Year: %d\nSubscriber amount Claimed: %d\nSubscriber Remaining Claimed: %d\n", claims[j].id, patients[i].name, claims[j].claimedYear, claims[j].amountClaimed, claims[j].remaininigAmount);

system("pause");

}

Solutions

Expert Solution

Function

void claimProcess(){ //function claimProcess(no return type)
int id;
bool found = false;

system("cls"); //clearing the screen

printf("Enter patient ID for which you want to claim insurrence: ");
scanf("%d", & id); //Input id

int i;
for (i = 0; i < patientCount; i++){ //Loop upto Total patient
if (patients[i].id == id){ //if input id matches the patient id that means patient founded
found = true;
break;
}
}

if (found == false){ //if patient not found then exit the program
printf("subscriber not found\n");
return;
}

int numOfDaysHospitalized, suppliesCost, surgicalFee, otherCharges;
bool ICU;

printf("How many days were you haspitalized: ");
scanf("%d", & numOfDaysHospitalized); //Input from how many days you are in hospital

int ICUFlag;
do { //do while loop
printf("Select A Ward Type\n1-Normal Ward 2-ICU: ");
scanf("%d", & ICUFlag); //Input Ward Type(1 or 2)
} while (ICUFlag < 1 || ICUFlag > 2); //if Ward Type other than 1 or 2 the exit from the loop

if (ICUFlag == 2) //if Ward Type is 2 means patient is in ICU
ICU = true;
else //if Ward Type is 1 means patient not in ICU
ICU = false;

printf("Enter Cost of Supplies and Services: ");
scanf("%d", & suppliesCost); //Input supplies Cost

printf("Enter Surgical Fees: ");
scanf("%d", & surgicalFee); //Input surgicalFee

printf("Enter Other Charges: ");
scanf("%d", & otherCharges); //Input otherCharges

int ICUCharges = 0;
if (ICU == true){ //if patient in ICU
if (patients[i].plan == 1)
ICUCharges = numOfDaysHospitalized * 120; //if plan=1 then charges 120/day
else if (patients[i].plan == 2)
ICUCharges = numOfDaysHospitalized * 150; //if plan=2 then charges 150/day
else
ICUCharges = numOfDaysHospitalized * 200; //if plan other than 1 or 2 then charges 200/day
}
else{ //If patient is not in ICU
if (patients[i].plan == 1)   
ICUCharges = numOfDaysHospitalized * 250; //if plan=1 then charges 250/day
else if (patients[i].plan == 2)
ICUCharges = numOfDaysHospitalized * 400;//if plan=2 then charges 400/day
else
ICUCharges = numOfDaysHospitalized * 700; //if plan other than 1 or 2 then charges 700/day
}

//totalClaimAmount
int totalClaimAmount = numOfDaysHospitalized + suppliesCost + surgicalFee + otherCharges + ICUCharges;
if (patients[i].annualClaim == true){ //if patient have annualClaim and age greater than 60 they are not eligible to claim
if (patients[i].age > 60){
printf("The subscriber age has exceeded the limit(60 Year), Not Eligible");
return;
}
}

int j;
for (j = 0; j < patientCount; j++){//loop total patient
if (claims[j].id == patients[i].id) //if clame id matches with patient id then exit from the loop
break;
}
int amountToBeBorne = 0;
if (totalClaimAmount <= claims[j].remaininigAmount){//if totalClaimAmount less than claim(remaininigAmount)
claims[j].amountClaimed += totalClaimAmount; //then add totalClaimAmount to claim(amountClaimed)
claims[j].remaininigAmount -= totalClaimAmount;//and subtract totalClaimAmount to claim(remaininigAmount)
}
else{ //if totalClaimAmount greater than claim(remaininigAmount)
amountToBeBorne = totalClaimAmount - claims[j].remaininigAmount;//then subtract claim(remaininigAmount) to totalClaimAmount and pay amountToBeBorne
claims[j].amountClaimed += (totalClaimAmount - amountToBeBorne);//and add claim(amountClaimed) to (totalClaimAmount subtract to amountToBeBorne)
claims[j].remaininigAmount = 0; //and claims(remaininigAmount ) is left zero
printf("\n\nThe amount that can be claimed is less then the claim by subscriber. %d RM should be given by subscriber themselves\n", amountToBeBorne);
}

FILE * fp;
fp = fopen("claims.txt", "w");//open file claims.txt to write data

for (int i = 0; i < patientCount; i++)//loop upto total patient
fprintf(fp, "%d,%d,%d,%d\n", claims[i].id, claims[i].claimedYear, claims[i].amountClaimed, claims[i].remaininigAmount);//write into file claims(id,claimedYear,amountClaimed,remaininigAmount)

fclose(fp); //close file
//print on console claims(id,claimedYear,amountClaimed,remaininigAmount) patients(name)
printf("Subscriber ID: %d\nSubscriber Name: %s\nSubscriber Claimed Year: %d\nSubscriber amount Claimed: %d\nSubscriber Remaining Claimed: %d\n", claims[j].id, patients[i].name, claims[j].claimedYear, claims[j].amountClaimed, claims[j].remaininigAmount);
system("pause");//program waits to be terminated
}

Explanation

function claimProcess(no return type)

Input id

Loop upto Total patient

if input id matches the patient id that means patient founded

if patient not found then exit the program

Input from how many days you are in hospital

do while loop

  Input Ward Type(1 or 2)

if Ward Type other than 1 or 2 the exit from the loop

if Ward Type is 2 means patient is in ICU

else Ward Type is 1 means patient not in ICU

Input supplies Cost ,surgicalFee,otherCharges

if patient in ICU

if plan=1 then charges 120/day

if plan=2 then charges 150/day

else plan other than 1 0r 2 then charges 200/day

else patient is not in ICU

if plan=1 then charges 250/day

if plan=2 then charges 400/day

else plan other than 1 or 2 then charges 700/day

totalClaimAmount = numOfDaysHospitalized + suppliesCost + surgicalFee + otherCharges + ICUCharges;

if patient have annualClaim and age greater than 60 they are not eligible to claim

loop total patient

  if clame id matches with patient id then exit from the loop

if totalClaimAmount less than claim(remaininigAmount)

  then add totalClaimAmount to claim(amountClaimed) and subtract totalClaimAmount to claim(remaininigAmount)

else totalClaimAmount greater than claim(remaininigAmount)

  then subtract claim(remaininigAmount) to totalClaimAmount and pay amountToBeBorne

  and add claim(amountClaimed) to (totalClaimAmount subtract to amountToBeBorne)

  and claims(remaininigAmount ) is left zero

open file claims.txt to write data

loop upto total patient

  write into file claims(id,claimedYear,amountClaimed,remaininigAmount)

close file

print on console claims(id,claimedYear,amountClaimed,remaininigAmount) patients(name)

program waits to be terminated


Related Solutions

Hello sir below is my code can you plz explain it line by line in details...
Hello sir below is my code can you plz explain it line by line in details #include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<string.h> #include<time.h> struct patient { int id; int age; bool annualClaim; int plan; char name[30]; char contactNum[15]; char address[50]; }; #define MAX_LENGTH 500 struct patient patients[100]; int patientCount = 0; struct claim { int id; int claimedYear; int amountClaimed; int remaininigAmount; }; struct claim claims[100]; void subscribe() { system("cls"); patients[patientCount].id = patientCount + 1; printf("Enter age: "); scanf("%d", & patients[patientCount].age); printf("\n\n%-25sHealth...
Explain the code below in details. void accountInfo() { system("cls"); int ch; printf("1-Total Amount Claimed by...
Explain the code below in details. void accountInfo() { system("cls"); int ch; printf("1-Total Amount Claimed by LifeTime Claim Limit subscriber\n"); printf("2-Total number of Annual Claim Limit who have exhausted all their eligible amount\n"); scanf("%d", & ch); if (ch == 1) { int totalAmountClaimedByLifeTimeSubs = 0; for (int i = 0; i < patientCount; i++) { if (patients[i].annualClaim == false) { for (int j = 0; j < patientCount; j++) { if (claims[j].id == patients[i].id) { totalAmountClaimedByLifeTimeSubs += claims[j].amountClaimed; } }...
Hello sir can you plz change my below code like change names , function name and...
Hello sir can you plz change my below code like change names , function name and add comments so it wont look same but run same. change as much as you can thank you. #include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<string.h> #include<time.h> struct patient { int id; int age; bool annualClaim; int plan; char name[30]; char contactNum[15]; char address[50]; }; #define MAX_LENGTH 500 struct patient patients[100]; int patientCount = 0; struct claim { int id; int claimedYear; int amountClaimed; int remaininigAmount; }; struct...
Please explain this code line by line void printperm(int *A,int n,int rem,int j) {    if(n==1)...
Please explain this code line by line void printperm(int *A,int n,int rem,int j) {    if(n==1)       {        for(int k=0;k<j;k++)        cout<<A[k]<<" + ";        cout<<rem<<"\n";        return;       }     for(int i=0;i<=rem;i++)    {          if(i<=rem)          A[j]=i;          printperm(A,n-1,rem-i,j+1);    } }
What is the ouput of the following code? void loop(int num) { for(int i = 1;...
What is the ouput of the following code? void loop(int num) { for(int i = 1; i < num; ++i) { for(int j = 0; j < 5; ++j) { cout << j; } } } int main() { loop(3); return 0; }
Consider the following code: void swap(int arr[], int i, int j) {        int temp = arr[i];...
Consider the following code: void swap(int arr[], int i, int j) {        int temp = arr[i];        arr[i] = arr[j];        arr[j] = temp; } void function(int arr[], int length) {        for (int i = 0; i<length / 2; i++)               swap(arr, i, (length / 2 + i) % length); } If the input to the function was int arr[] = { 6, 1, 8, 2, 5, 4, 3, 7 }; function(arr,8); What values would be stored in the array after calling the...
why my code for mergesort always wrong ? void Merge(vector<int>& data, int p, int q, int...
why my code for mergesort always wrong ? void Merge(vector<int>& data, int p, int q, int r) { int n1 = q - p + 1; int n2 = r - q; vector<int>left(n1); vector<int>right(n2); for(int i = 0; i < n1; i++) { left[i] = data[p + i]; } for(int j = 0; j < n2; j++) { right[j] = data[q+j+1]; } int i = 0; int j = 0; for(int k = p; k <= r; k++) { if(left[i]...
hello , could you please answer this question for me in details , my teacher want...
hello , could you please answer this question for me in details , my teacher want more than 400 word ?. it is an essay . 1) Discuss the application of Classical conditioning in reducing Anxiety.!!
Hello can someone please explain the AS AD curve step by step to me? Thank you
Hello can someone please explain the AS AD curve step by step to me? Thank you
my code is not printing the output #include <stdio.h> #include<stdbool.h> int main(){ // variable declarations   bool...
my code is not printing the output #include <stdio.h> #include<stdbool.h> int main(){ // variable declarations   bool binary[12] = {false,false, false, false,false,false,false,false,false,false,false, false};   int powerTwo[12] = {2048.1028,576, 256, 128, 64, 32, 16, 8 , 4, 2, 1};   int oneZero[9]= {0,0,0,0,0,0,0,0,0};   int tempVal = 0;   double decimal = 0;   int i = 0;   int j = 0;   // Intialization   printf("Starting the CPSC 1011 Decimal to Binary Converter!\n");   printf("Please enter a positive whole number (or EOF to quit): \n");   scanf("%lf", &decimal);   printf("%lf", decimal);...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT