Question

In: Computer Science

Make pesodocode of this code. void loadData() { char line[MAX_LENGTH]; const char * delimiter = ",\n";...

Make pesodocode of this code.

void loadData()
{
char line[MAX_LENGTH];
const char * delimiter = ",\n";
FILE * fp;
fp = fopen("patients.txt", "r");
char c;
if (fp == NULL)
{
printf("file not found");
return;
}
while (fp != NULL)
{
if (fgets(line, MAX_LENGTH - 1, fp) == NULL)
break;
if (line[1] == '\0')
break;
patients[patientCount].id = atoi(strtok(line, delimiter));
strcpy(patients[patientCount].name, strtok(NULL, delimiter));
patients[patientCount].age = atoi(strtok(NULL, delimiter));
patients[patientCount].annualClaim = strtok(NULL, delimiter);
patients[patientCount].plan = atoi(strtok(NULL, delimiter));
strcpy(patients[patientCount].contactNum, strtok(NULL, delimiter));
strcpy(patients[patientCount].address, strtok(NULL, delimiter));
strcpy(line, "\0");
patientCount++;
}
fclose(fp);
fp = fopen("claims.txt", "r");
int claimCount = 0;
while (fp != NULL)
{
if (fgets(line, MAX_LENGTH - 1, fp) == NULL)
break;
if (line == "\n")
break;
claims[claimCount].id = atoi(strtok(line, delimiter));
claims[claimCount].claimedYear = atoi(strtok(NULL, delimiter));
claims[claimCount].amountClaimed = atoi(strtok(NULL, delimiter));
claims[claimCount].remaininigAmount = atoi(strtok(NULL, delimiter));
strcpy(line, "\0");
claimCount++;
}
fclose(fp);
}
int menu()
int ch;
do {
system("cls");
printf("Select one of the below option to continue\n");
printf("1-Insurence Plan Subscription\n");
printf("2-Claim Processing\n");
printf("3-Accounts Information\n");
printf("4-Searching Functionalities\n");
printf("5-Exit\n");
scanf("%d", & ch);
} while (ch > 5 || ch < 1);
return ch;
}
int main()
{
int ch;
loadData();
do {
ch = menu();
if (ch == 1)
subscribe();
else if (ch == 2)
claimProcess();
else if (ch == 3)
accountInfo();
else if (ch == 4)
searchingFunctionalities();
else
break;
} while (ch != 5);
system("pause");
return 0;
}

Solutions

Expert Solution

Pseudo code of the above code is as follows,

Function loadData(){

set delimiter as newline.

open file "patients.txt" in read mode and

if file has no data

then display "File not found"

return pointer

EndIf

Precondition : File has data

  

While file has data do the following

If file has only one data

Then exit from loop.

If file line has   the end of the character

Then exit from loop .

Read the id of the patient from file.convert it into integer from string format.split from the line using delimiter.

Copy the name from the file into name using the delimiter to split the name from file.

Read the age of the patient from file.

Read the annual claim of the patient from file.

Read the plan from the file.

Copy the contact number of patient from file .

  Copy the address of patient file.

Copy the end of string character.

Close the file "patient.txt".

Open the file "claim.txt" in read mode.

While file has data do the following

If file has one data

Then exit from loop.

If file has only new line,

Then break from loop.

Read id from the file .

Read claimed Year from file.

Read amount to claim from file.

Read the remaining amount from file.

End the file using the end of string character.

Close the file "Claim.txt"

Close the function loadData.

}

Function menu(){

Do the following until the user reads character greater than 5 or lesser than 1.

Display menu as follows

Display "select one of the below option to continue".

Display "1-Insurance plan Subscription" in next line.   

Display "2-Claim Processing" in next line.

Display "3-Accounts information" in next line.

Display "4-Searching Functionalities" in next line.

  Display "5-Exit" in next line.

Return character.

}

Function main(){

Read the character from user.

Call function loadData().

Do the following unti the character not equals 5.

If the character equals 1

Then call function subscribe ().

Else if character equals 2

Then call function ClaimProcess().

Else if character equals 3

Then call function AccountInfo().

Else if character equals 4

Then call function searchingFunctionalities().

Else

return from function.

Exit from main function.

}


Related Solutions

Given the root C++ code: void sort() {    const int N = 10;    int...
Given the root C++ code: void sort() {    const int N = 10;    int x[N];    for(int i = 0; i < N; i++)    {        x[i] = 1 + gRandom-> Rndm() * 10;        cout<<x[i]<<" "; }    cout<<endl;    int t;       for(int i = 0; i < N; i++)    {    for(int j = i+1; j < N; j++)    {        if(x[j] < x[i])        {   ...
convert the code to the flow chart char counter; void wait() { delay_ms(1000); } void main()...
convert the code to the flow chart char counter; void wait() { delay_ms(1000); } void main() { TRISB=0x00; // set direction to be output PORTA=0x00; // turn off the PORTA leds PORTB=0x00; // turn off the PORTB leds PORTC=0x00; // turn off the PORTC leds PORTD=0x00; // turn off the PORTD leds while (1){ for (counter = 15; counter>0 ; counter= --) { PORTB = counter; wait(); } } }
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);    } }
Create a C module convertTo_csv.c that will implement the function loadAndConvert(const char* file) The code must...
Create a C module convertTo_csv.c that will implement the function loadAndConvert(const char* file) The code must be split into 2 files (.h file and a .c file). The convertTo_csv.c will have the function implementation in ti and the The convertTo_csv.h file will have the declaration. One argument will be given to the function, that is the name of the input file that needs to be converted. A function will create a new csv file called output.csv Know that the loadAndConvert...
Given a class Stack with the interface public void push(char n) // pushes n onto stack...
Given a class Stack with the interface public void push(char n) // pushes n onto stack public char pop() // return the top of the stack, removing element from stack public boolean isEmpty() // return true if stack is empty Write a method public int removeX(Stack<Character> stack) which takes a stack of Characters, removes the occurrences of ‘X’ and returns the count of the number of Xs removed. It must restore the stack to its original order (less the Xs)....
Why is my C code counter returning the wrong output? void removeLn(char *tPtr) { for (;...
Why is my C code counter returning the wrong output? void removeLn(char *tPtr) { for (; *tPtr != '\0'; tPtr++) { if (*tPtr == '\n') { *tPtr = '\0'; } } } This is a method I wrote that essentially replaces the \n in a text file with a null. int counter(FILE *filePtr) { char ln[length]; int counter = 0; while (fgets(ln, length, filePtr) != NULL) { char *r;    for (r = ln; *r != '\0';) { while (isspace(*r))...
Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1;...
Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1; char ch2; int main() { cin.get(ch1); cin.get(ch2);    cout << ch1 << chConst << ch2;    return 0; }
C++ QUESTION ABOUT FIXING CODE AND RUNNING TESTS: class SpeakerSystem { public: void vibrateSpeakerCones(unsigned signal) const...
C++ QUESTION ABOUT FIXING CODE AND RUNNING TESTS: class SpeakerSystem { public: void vibrateSpeakerCones(unsigned signal) const { cout << "Playing: " << signal << "Hz sound..." << endl; cout << "Buzz, buzzy, buzzer, bzap!!!\n"; } }; class Amplifier { public: void attachSpeakers(const SpeakerSystem& spkrs) { if(attachedSpeakers) cout << "already have speakers attached!\n"; else attachedSpeakers = &spkrs; }    void detachSpeakers() { // should there be an "error" message if not attached? attachedSpeakers = nullptr; }    void playMusic( ) const...
Define the meaning of following java code in public void refer, line by line. thank you...
Define the meaning of following java code in public void refer, line by line. thank you public class LRUCache {     // store keys of cache     static Deque<Integer> dq;     // store references of key in cache     static HashSet<Integer> map;     // maximum capacity of cache     static int csize;        LRUCache(int n)     {         dq = new LinkedList<>();         map = new HashSet<>();         csize = n;     }     public void refer(int x)     {         if (!map.contains(x)) {             if (dq.size() == csize) {                 int last = dq.removeLast();                 map.remove(last);...
Topic: Template template void arrayContents(const T *arr, int countSize); int main() { const int ACOUNT =...
Topic: Template template void arrayContents(const T *arr, int countSize); int main() { const int ACOUNT = 5; const int BCOUNT = 7; const int CCOUNT = 6; int a[ACOUNT] = {1, 2, 3, 4, 5}; double b[BCOUNT] = {1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7}; char c[CCOUNT] = "HELLO"; cout <<"Array A contents: \n"; arrayContents(a, ACOUNT); cout <<"Array B contents: \n"; arrayContents(b, BCOUNT); cout <<"Array C contents: \n"; arrayContents(c, CCOUNT); return 0; } template void arrayContents(const T *arr, int countSize)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT