108k views
0 votes
In order to ensure transparency in Covid-19 vaccination program, you need to design a computer program to count the total number of different types (Pfizer, Moderna, AstraZeneca, Sino pharm, Sputnik V) of vaccines given to individuals in a vaccination center. Just after getting the vaccine jab, individuals need to enter in a computer program a number as per the following menu to confirm the vaccine type he/she obtained. Your program should display the following menu of alternatives: Enter 1 for "Pfizer" Enter 2 for "Moderna" Enter 3 for "AstraZeneca" Enter 4 for " Sino pharm" Enter 5 for "Sputnik V" You will use an array to solve this problem. Each array element keeps track of the count of a given type of vaccine administered. Each center can vaccinate atmost 300 individuals. At the end, your program should display the total count of vaccines of each type that has been administered i.e. the total number of Pfizer vaccine given, Moderna vaccine given etc. in a vaccination center on a particular day.

User Jesbin MJ
by
8.0k points

1 Answer

3 votes
To keep track of the number of different types of vaccines administered, we can use an array. We can initialize the array with all zeros, and then increment the element corresponding to the vaccine type that the individual received. Here is a sample program in Python:

```
# Initialize the array with all zeros
vaccine_counts = [0, 0, 0, 0, 0]

# Get the number of individuals vaccinated
num_vaccinated = int(input("Enter the number of individuals vaccinated: "))

# Loop through each individual and get the vaccine type
for i in range(num_vaccinated):
vaccine_type = int(input("Enter the vaccine type (1=Pfizer, 2=Moderna, 3=AstraZeneca, 4=Sino pharm, 5=Sputnik V): "))
vaccine_counts[vaccine_type-1] += 1

# Display the total count of vaccines of each type administered
print("Total number of Pfizer vaccines administered:", vaccine_counts[0])
print("Total number of Moderna vaccines administered:", vaccine_counts[1])
print("Total number of AstraZeneca vaccines administered:", vaccine_counts[2])
print("Total number of Sino pharm vaccines administered:", vaccine_counts[3])
print("Total number of Sputnik V vaccines administered:", vaccine_counts[4])
```

This program prompts the user for the number of individuals vaccinated, and then loops through each individual and prompts them for the vaccine type. It then increments the corresponding element in the `vaccine_counts` array. Finally, it displays the total count of each type of vaccine administered.
User Jacob Robbins
by
8.2k points