CT018-3-1 Introduction to C Programming Individual Assignment Page 2 of 8 Assume that all these vaccines have been approved by the Malaysian government and the above-mentioned pharmaceutical company needs a Vaccine Inventory Management System to allow its employees to carry out the following: 1. Inventory Creation. The system should provide a feature for the employees to permanently record vaccine details shown in Table 1 into a text file named as vaccine.txt. Initial quantity of each vaccine (in millions) also needs to be recorded in this file. Note: Initial quantity of vaccine is to be decided by the programmer. The records in the vaccine.txt file should be available every time the program is executed. 2. Update vaccine quantities. The system should allow the employees to select a particular vaccine and indicate either received or distributed quantity. In either case, the quantity of the selected vaccine needs to be updated accordingly in the vaccine.txt file. E.g. Assume that the initial quantity of Pfizer vaccine in vaccine.txt file is 1 million. When the company receives a new stock, this quantity has to be added to the existing quantity of 1 million in the vaccine.txt file. In the case where the vaccines are distributed to hospitals for vaccination, the distributed quantity has to be subtracted from the quantity available in the vaccine.txt file. Note: Whenever a vaccine is distributed to hospitals, its code and the quantity distributed need to be recorded into a text file named as dist.txt. Each vaccine is expected to be distributed more than once. Hence, while testing the program, there should be at least 10 records created in the dist.txt file. 3. Search vaccine and its available quantity by using vaccine code. The system should have a feature for employees to query a particular vaccine's existing quantity from the vaccine.txt file using vaccine code. 4. Produce a list of all vaccines and their distributed quantities . The system should allow the employees to list all distributed vaccines and their accumulated quantities read from the dist.txt file. Note: The vaccines and their distributed quantities need to be sorted ascendingly (with highest quantity listed first followed by second highest and so on) using Bubble sort before displaying on the screen.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Following things I want 

 

  1.  Flow chart 
  2. Psuedo Code 
  3.  Dist.txt
  4.  Header file
  5.  Requirement 4: DESCENDING ORDER (NOT ASCENDING ORDER) 4. Produce a list of all vaccines and their distributed quantities . The system should allow the employees to list all distributed vaccines and their accumulated quantities read from the dist. txt file. Note: The vaccines and their distributed quantities need to be sorted in descending order (with highest quantity listed first followed by second highest and so on) using Bubble sort before displaying on the screen.

 

MY CODE:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

// Function Declarations

void create_inventory();

void update_vacc_qty();

int search_vaccine();

void display_vaccine();

// Main Function starts here

int main()

{

create_inventory();

display_vaccine();

search_vaccine();

//update_vacc_qty();

return 0;

}

//Function to Create Vaccine.txt as per the given table

void create_inventory()

{

int option = 1;

// variables to collect data as per table given

char vaccName[15];

char vaccCode[2];

char country[15];

int qty;

float populaion;

//File definition

FILE *infile;

infile = fopen("Vaccine.txt","w"); // file opening for writing

if(infile == NULL) // Checking for the file creation

{

printf("Vaccine.txt file not found\n");

}

//Accepting data from user from keyboard till user enters 0 to close

while(option != 0)

{

printf("Enter Vaccine Name : ");

scanf("%s",vaccName);

printf("Enter Vaccine Code : ");

scanf("%s",vaccCode);

printf("Enter Counry : ");

scanf("%s",country);

printf("Enter Dosage Required : ");

scanf("%d",&qty);

printf("Enter Population Covered : ");

scanf("%f",&populaion);

//writing to the file using fprintf command

fprintf(infile,"%s %s %s %d %3.2f\n",

vaccName,vaccCode,country,qty,populaion);

printf("\nEnter 1 to continue and 0 to exit : ");

scanf("%d",&option);

if(option == 0)

fclose(infile); // closing the file when user wants to exit

}

}

//Function to display the file contents in a formatted way

void display_vaccine()

{

// variables to collect data as per table given

char vaccName[15];

char vaccCode[2];

char country[15];

int qty;

float populaion;

FILE *infile;

infile = fopen("Vaccine.txt","r"); // file opening for reading

if(infile == NULL) //checking for file exists or not

{

printf("Vaccine.txt file not found\n");

}

//printing the header line

printf("%15s\t%2s\t%15s\t%6s\t%10s\n","Vaccine Name","Vaccine Code","Country","Dosage","Population");

// Reading the file

while(fscanf(infile,"%s %s %s %d %f\n",vaccName,vaccCode,country,&qty,&populaion) !=EOF)

{

//printing the read data in a formatted way

printf("%15s\t%13s\t%15s\t%d\t%3.2f\n",vaccName,vaccCode,country,qty,populaion);

}

fclose(infile); // closing the file

}

void update_vacc_qty()

{

// to be coded

}

int search_vaccine()

{

// variables to collect data as per table given

char vaccName[15];

char vaccCode[2];

char country[15];

int qty;

float populaion;

FILE *infile;

char vcode[2];

char temp[2];

int value;

infile = fopen("Vaccine.txt","r"); // file opening for reading

//getting the vaccine code from user through keyboard to search

printf("Enter Vaccine Code to Search : ");

scanf("%s",vcode);

if(infile == NULL) // checking for file existence

{

printf("Vaccine.txt file not found\n");

}

strcpy(temp,vcode);

//Reading the file

while(fscanf(infile,"%s %s %s %d %f\n",vaccName,vaccCode,country,&qty,&populaion) !=EOF)

{

//checking user entered vaccine code and available in the file is same

if(vaccCode[0] == temp[0] && vaccCode[1] == temp[1])

{

// Printing the matched record

printf("%15s\t%2s\t%15s\t%6s\t%10s\n","Vaccine Name"," Vaccine Code","Country","Dosage","Population");

printf("%15s\t%13s\t%15s\t%d\t%3.2f\n",vaccName,vaccCode,country,qty,populaion);

}

}

fclose(infile);// closing the file

}//end of Program

CT018-3-1 Introduction to C Programming
Individual Assignment
Page 1 of 8
Course Learning Outcomes:
Upon completion of this assignment you should be able to:
CLO1
Explain the essential facts, concepts, principles, strategies and
theories relating to Information Technology applications. (C2,
Class Test
PLO1)
Demonstrate intellectual independence, logical and
analytical thinking skills to develop creative and innovative | Assignment
solutions for a range of Information management and IT
problems. (C3, PLO2)
Communicate effectively and professionally with peers,
CLO2
Individual
CLO3
Individual
clients, superiors and society at large both in written and
spoken form. (A3, PLO5)
Assignment
1.0
INDIVIDUAL ASSIGNMENT DESCRIPTION
VACCINE INVENTORY MANAGEMENT SYSTEM
Coronavirus or severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) is a deadly
virus that has caused global pandemic. The virus causes respiratory tract infections that
can range from mild to lethal. The World Health Organization (WHO) has named the
disease caused by coronavirus as coronavirus disease (COVID-19).
As of now, there is no specific medication available nor drugs discovered for treating
COVID-19 patients. Thus, hospitals usually provide supportive care to COVID-19 patients
as part of their treatment procedure. This includes treatment to relieve symptoms, fluid
therapy, oxygen support and prone positioning as needed, and medications or devices to
support other affected vital organs.
The COVID-19 vaccination is found to be a safer way to help build protection against the
virus and end the pandemic. This has made pharmaceutical companies to race against time
and develop vaccine to save the lives of mankind. At present, the vaccination process has
started in many countries including Malaysia. The vaccine warehousing and distribution in
Malaysia is done by an authorised pharmaceutical company. The types of vaccine planned
for people in Malaysia is shown in Table 1 as follows:
Table 1: Types of Vaccine
Name of Vaccine
Vaccine Code Producing Country Dosage Required Population Covered (%)
Pfizer
PF
USA
2
50
Sinovac
SV
China
2
18.8
AstraZeneca
AZ
UK
10
Sputnik V
SP
Russia
2
10
CanSinoBio
CS
China
1
10.9
Level 1
Asia Pacific University of Technology & Innovation
05/2021
Transcribed Image Text:CT018-3-1 Introduction to C Programming Individual Assignment Page 1 of 8 Course Learning Outcomes: Upon completion of this assignment you should be able to: CLO1 Explain the essential facts, concepts, principles, strategies and theories relating to Information Technology applications. (C2, Class Test PLO1) Demonstrate intellectual independence, logical and analytical thinking skills to develop creative and innovative | Assignment solutions for a range of Information management and IT problems. (C3, PLO2) Communicate effectively and professionally with peers, CLO2 Individual CLO3 Individual clients, superiors and society at large both in written and spoken form. (A3, PLO5) Assignment 1.0 INDIVIDUAL ASSIGNMENT DESCRIPTION VACCINE INVENTORY MANAGEMENT SYSTEM Coronavirus or severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) is a deadly virus that has caused global pandemic. The virus causes respiratory tract infections that can range from mild to lethal. The World Health Organization (WHO) has named the disease caused by coronavirus as coronavirus disease (COVID-19). As of now, there is no specific medication available nor drugs discovered for treating COVID-19 patients. Thus, hospitals usually provide supportive care to COVID-19 patients as part of their treatment procedure. This includes treatment to relieve symptoms, fluid therapy, oxygen support and prone positioning as needed, and medications or devices to support other affected vital organs. The COVID-19 vaccination is found to be a safer way to help build protection against the virus and end the pandemic. This has made pharmaceutical companies to race against time and develop vaccine to save the lives of mankind. At present, the vaccination process has started in many countries including Malaysia. The vaccine warehousing and distribution in Malaysia is done by an authorised pharmaceutical company. The types of vaccine planned for people in Malaysia is shown in Table 1 as follows: Table 1: Types of Vaccine Name of Vaccine Vaccine Code Producing Country Dosage Required Population Covered (%) Pfizer PF USA 2 50 Sinovac SV China 2 18.8 AstraZeneca AZ UK 10 Sputnik V SP Russia 2 10 CanSinoBio CS China 1 10.9 Level 1 Asia Pacific University of Technology & Innovation 05/2021
CT018-3-1 Introduction to C Programming
Individual Assignment
Page 2 of 8
Assume that all these vaccines have been approved by the Malaysian government and the
above-mentioned pharmaceutical company needs a Vaccine Inventory Management
System to allow its employees to carry out the following:
1. Inventory Creation. The system should provide a feature for the employees to
permanently record vaccine details shown in Table 1 into a text file named as
vaccine.txt. Initial quantity of each vaccine (in millions) also needs to be recorded in
this file.
Note: Initial quantity of vaccine is to be decided by the programmer. The records in the
vaccine.txt file should be available every time the program is executed.
2. Update vaccine quantities. The system should allow the employees to select a
particular vaccine and indicate either received or distributed quantity. In either case,
the quantity of the selected vaccine needs to be updated accordingly in the vaccine.txt
file.
E.g. Assume that the initial quantity of Pfizer vaccine in vaccine.txt file is 1 million.
When the company receives a new stock, this quantity has to be added to the existing
quantity of 1 million in the vaccine.txt file. In the case where the vaccines are distributed
to hospitals for vaccination, the distributed quantity has to be subtracted from the
quantity available in the vaccine.txt file.
Note: Whenever
a vaccine is distributed to hospitals, its code and the quantity
distributed need to be recorded into a text file named as dist.txt. Each vaccine is
expected to be distributed more than once. Hence, while testing the program, there
should be at least 10 records created in the dist.txt file.
3. Search vaccine and its available quantity by using vaccine code. The system should
have a feature for employees to query a particular vaccine's existing quantity from the
vaccine.txt file using vaccine code.
4. Produce a list of all vaccines and their distributed quantities . The system should allow
the employees to list all distributed vaccines and their accumulated quantities read from
the dist.txt file.
Note: The vaccines and their distributed quantities need to be sorted ascendingly (with
highest quantity listed first followed by second highest and so on) using Bubble sort
before displaying on the screen.
Level 1
Asia Pacific University of Technology & Innovation
05/2021
Transcribed Image Text:CT018-3-1 Introduction to C Programming Individual Assignment Page 2 of 8 Assume that all these vaccines have been approved by the Malaysian government and the above-mentioned pharmaceutical company needs a Vaccine Inventory Management System to allow its employees to carry out the following: 1. Inventory Creation. The system should provide a feature for the employees to permanently record vaccine details shown in Table 1 into a text file named as vaccine.txt. Initial quantity of each vaccine (in millions) also needs to be recorded in this file. Note: Initial quantity of vaccine is to be decided by the programmer. The records in the vaccine.txt file should be available every time the program is executed. 2. Update vaccine quantities. The system should allow the employees to select a particular vaccine and indicate either received or distributed quantity. In either case, the quantity of the selected vaccine needs to be updated accordingly in the vaccine.txt file. E.g. Assume that the initial quantity of Pfizer vaccine in vaccine.txt file is 1 million. When the company receives a new stock, this quantity has to be added to the existing quantity of 1 million in the vaccine.txt file. In the case where the vaccines are distributed to hospitals for vaccination, the distributed quantity has to be subtracted from the quantity available in the vaccine.txt file. Note: Whenever a vaccine is distributed to hospitals, its code and the quantity distributed need to be recorded into a text file named as dist.txt. Each vaccine is expected to be distributed more than once. Hence, while testing the program, there should be at least 10 records created in the dist.txt file. 3. Search vaccine and its available quantity by using vaccine code. The system should have a feature for employees to query a particular vaccine's existing quantity from the vaccine.txt file using vaccine code. 4. Produce a list of all vaccines and their distributed quantities . The system should allow the employees to list all distributed vaccines and their accumulated quantities read from the dist.txt file. Note: The vaccines and their distributed quantities need to be sorted ascendingly (with highest quantity listed first followed by second highest and so on) using Bubble sort before displaying on the screen. Level 1 Asia Pacific University of Technology & Innovation 05/2021
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY