Advertisement
LEGEND2004

Vaccine

Apr 10th, 2023
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.37 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct Date {
  5.     int day;
  6.     int month;
  7.     int year;
  8. };
  9.  
  10. struct Time {
  11.     int hours;
  12.     int minutes;
  13. };
  14.  
  15. struct VaccinationPlace {
  16.     char name[50];
  17.     char address[100];
  18.     int capacity;
  19. };
  20.  
  21. struct Vaccine {
  22.     char name[50];
  23.     char manufacturer[50];
  24.     int dosesRequired;
  25. };
  26.  
  27. struct Person {
  28.     char name[50];
  29.     int age;
  30.     char address[100];
  31. };
  32.  
  33. struct Appointment {
  34.     struct Date date;
  35.     struct Time time;
  36.     struct VaccinationPlace place;
  37.     struct Vaccine vaccine;
  38.     struct Person person;
  39. };
  40.  
  41. struct Supply {
  42.     struct Vaccine vaccine;
  43.     int quantity;
  44. };
  45.  
  46. void printAppointment(struct Appointment appt) {
  47.     printf("Appointment Details:\n");
  48.     printf("Date: %d/%d/%d\n", appt.date.day, appt.date.month, appt.date.year);
  49.     printf("Time: %d:%02d\n", appt.time.hours, appt.time.minutes);
  50.     printf("Vaccination Place: %s (%s)\n", appt.place.name, appt.place.address);
  51.     printf("Vaccine: %s by %s (%d doses required)\n", appt.vaccine.name, appt.vaccine.manufacturer, appt.vaccine.dosesRequired);
  52.     printf("Person: %s (%d years old, %s)\n", appt.person.name, appt.person.age, appt.person.address);
  53. }
  54.  
  55. void printSupply(struct Supply supply) {
  56.     printf("Vaccine Supply:\n");
  57.     printf("Vaccine: %s by %s (%d doses required)\n", supply.vaccine.name, supply.vaccine.manufacturer, supply.vaccine.dosesRequired);
  58.     printf("Quantity: %d\n", supply.quantity);
  59. }
  60.  
  61. int main() {
  62.     // Create example data
  63.     struct Date apptDate = {10, 4, 2023};
  64.     struct Time apptTime = {12, 30};
  65.     struct VaccinationPlace apptPlace = {"Community Center", "123 Main St, Anytown, USA", 50};
  66.     struct Vaccine apptVaccine = {"Moderna", "Moderna, Inc.", 2};
  67.     struct Person apptPerson = {"John Doe", 35, "456 Elm St, Anytown, USA"};
  68.     struct Appointment appt = {apptDate, apptTime, apptPlace, apptVaccine, apptPerson};
  69.  
  70.     struct Vaccine supplyVaccine1 = {"Pfizer-BioNTech", "Pfizer, Inc.", 2};
  71.     struct Supply vaccineSupply1 = {supplyVaccine1, 100};
  72.  
  73.     struct Vaccine supplyVaccine2 = {"Johnson & Johnson", "Janssen Pharmaceuticals, Inc.", 1};
  74.     struct Supply vaccineSupply2 = {supplyVaccine2, 50};
  75.  
  76.     // Print example data
  77.     printAppointment(appt);
  78.     printf("\n");
  79.     printSupply(vaccineSupply1);
  80.     printf("\n");
  81.     printSupply(vaccineSupply2);
  82.  
  83.     return 0;
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement